[Seaside] Re: [Seaside-dev] Accessing service from a mail .

Gastón Dall' Oglio gaston.dalloglio at gmail.com
Mon Feb 25 20:51:48 UTC 2013


And here is an example of an method that generate text and html versions
[1]:

sendEmailChangeConfirmationTo: email confirmUrl: url timeout: timo newUser:
newUser
"Compose and send email. Answer true on success, false on failure."

| textBody htmlBody emailOk appName |
 appName := 'Login Test App'.
 textBody := (WriteStream on: String new)
<< 'This email is in response to your request change your '; << appName; <<
' email address.'; crlf;crlf;
<< 'Direct your browser to the following URL within ';<< timo asString; <<
' minutes to confirm this change'; crlf;crlf;
<< '         '; << url; crlf;crlf;
<< 'If you did not request an address change then this message may indicate
a beak-in attempt at ';<< appName; <<'.'.
 htmlBody := WAHtmlCanvas builder fullDocument: true; render: [ :html |
html div
style: 'font-size: 11pt';
with: [
html div
style: 'margin-bottom: 10px;';
with: 'This email is in response to your request change your ', appName, '
email address'.
html text: 'Click on the link below within ', timo asString, ' minutes to
confirm this change.'.
html div
style: 'margin-left:20pt;margin-top:10px;margin-bottom:10px;';
with: [
html anchor
url: url;
with: 'Confirm address change'].
html text: 'If the link above is unresponsive, copy and paste the URL below
into your browser''s address field to confirm the change.'.
html div
style: 'margin-left:20pt;margin-top:10px;margin-bottom:10px;';
with: url.
html text: 'If you did not request a change then this message may indicate
a beak-in attempt at ', appName, '.']].

(emailOk := self sendEmailTo: email subject:  appName, ' email address
change - action required' text: textBody html: htmlBody)
ifFalse: [ Transcript cr; show: url ].
 ^ emailOk


[1] I've taken most of this code of some objects that are part of TFLogin
http://www.tonyfleig.com/smallthoughts/tflogin

Regards.

2013/2/25 Gastón Dall' Oglio <gaston.dalloglio at gmail.com>

> A clarification, in line:
>
> mailMessage setField: 'from' toString: *from*
>
> *from* can be same as *user* or different, depending as your smtp server
> configuration.
>
>
> 2013/2/25 Gastón Dall' Oglio <gaston.dalloglio at gmail.com>
>
>> Hello.
>>
>> Set fullDocument to true to get a HTML Document with a head too, instead
>> only the body (but not if it is necessary to send html in an email):
>>  WAHtmlCanvas builder fullDocument: true; render: [ :html | ...
>>
>> I use this code for send email:
>>
>> sendEmailTo: to subject: subject text: textBody html: htmlBody
>> "Send multi-part MIME email message."
>>  | server port user password smtpClient mailMessage |
>>
>> server :=  (self application preferenceAt: #smtpServer).
>>  port := (self application preferenceAt: #smtpPort).
>> user := (self application preferenceAt: #smtpUsername).
>>  password := (self application preferenceAt: #smtpPassword).
>>
>>
>> [ mailMessage := MailMessage empty.
>>  mailMessage setField: 'from' toString: from.
>> mailMessage setField: 'to' toString: to.
>>  mailMessage setField: 'subject' toString: subject.
>> mailMessage addAlternativePart: textBody contents contentType:
>> 'text/plain'.
>>  mailMessage addAlternativePart: htmlBody contents contentType:
>> 'text/html'.
>>  (smtpClient := ZdcSecureSMTPClient new)
>> user: user;
>> password: password.
>>
>> smtpClient openOnHost: (NetNameResolver addressForName: server) port:
>> port.
>>
>> ^ smtpClient
>>  mailFrom: from to: { to } text: mailMessage text;
>> quit;
>> close;
>>  yourself ] on: Exception do: [ :ex | ^ false ].
>>
>>
>> Regards.
>>
>>
>> 2013/2/23 sarath raj <sarathraj99 at gmail.com>
>>
>>> soln i got , put this in WAEMailMessgage . header is needed
>>>
>>> headerAt: 'Content-type' put: 'text/html; charset=UTF-8'.
>>>
>>> Thanks
>>>
>>>
>>> On Sat, Feb 23, 2013 at 2:33 AM, Paul DeBruicker <pdebruic at gmail.com>wrote:
>>>
>>>> On 02/22/2013 12:26 AM, sarath raj wrote:
>>>> > 1) i created a REST Service in seaside sub class of WARestfulFilter  .
>>>> > 2) Another Class "testing" derived from WAComponent with a textfield
>>>> and
>>>> > button .
>>>> >
>>>> > Action : when i click the button it will send a mail that specified in
>>>> > the textfield , and the mail contains a link . that link represents
>>>> the
>>>> > REST service .
>>>> > When the user clicks the link , it will start redirect to REST
>>>> service .
>>>> >
>>>> > I done creating mail and all , but i am struck with how i can set a
>>>> body
>>>> > of a mail with html tags and all .
>>>> > Body contain the link to the service
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > seaside-dev mailing list
>>>> > seaside-dev at lists.squeakfoundation.org
>>>> > http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>>>> >
>>>>
>>>>
>>>> This would probably be better on the seaside users list, just because
>>>> more people read it and could respond.  So I cc'd it.
>>>>
>>>>
>>>> Do you want to send an html formatted email?  Is that what you're
>>>> asking?  I don't think you can right now, but it shouldn't be too hard
>>>> to get it working.
>>>>
>>>> You can get an html string like this:
>>>>
>>>> (WARenderCanvas builder render: [ :h | h heading level1; with: 'My
>>>> Email'.
>>>>         h image url: 'http://www.seaside.st/styles/logo-plain.png' ])
>>>>
>>>> But I don't know how to put it and a plain version of the body content
>>>> in the body plus declaring the content type in the body.  You'd need to
>>>> add the Content-Type in the email headers plus a boundary and then in
>>>> the body the boundary at the start of the plain & html sections then
>>>> also a Content-Type declaration for each section.
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> seaside mailing list
>>>> seaside at lists.squeakfoundation.org
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>>
>>>
>>>
>>> --
>>> Sarath Raj
>>>
>>> _______________________________________________
>>> seaside mailing list
>>> seaside at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20130225/16fa7cef/attachment.htm


More information about the seaside mailing list