1 ## Script (Python) "sendNotificationEmail"
2 ##bind container=container
6 ##bind subpath=traverse_subpath
10 #TODO : translate messages
11 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
12 #_ = MessageIDFactory('plinn')
13 #cmfMessages = MessageIDFactory('cmf_default')
14 _
= cmfMessages
= lambda x
: lambda : x
15 from quopri
import encodestring
17 portal
= context
.portal_url
.getPortalObject()
18 mtool
= portal
.portal_membership
19 rtool
= portal
.portal_registration
20 MailHost
= portal
.MailHost
23 def encodeAdr(member
) :
24 name
= member
.getMemberFullName(nameBefore
=0)
25 email
= member
.getProperty('email')
26 qpName
= encodestring(name
).replace('=\n', '')
27 return '''"=?utf-8?q?%s?=" <%s>''' % (qpName
, email
)
31 sender
= mtool
.getAuthenticatedMember()
32 sender
= encodeAdr(sender
)
33 mto
= encodeAdr(member
)
36 You have been registered as a member of "%(portal_title)s", which
37 allows you to personalize your view of the website and participate in
39 """.strip().replace('\n', ' ') )() % {'portal_title' :portal
.Title()}
41 if portal
.getProperty('validate_email') :
43 text
+= _( """You will receive an other mail with your randomly-generated
44 password. Once you have logged in with this password, you
45 may change it to anything you like.""".strip().replace('\n', ' ') )()
49 text
+= cmfMessages( "You can use this URL to log in:" )()
50 text
+= '\n' + portal
.absolute_url() + '/login_form'
52 message
= context
.echange_mail_template( From
= sender
54 , Subject
= "=?utf-8?q?%s?=" % encodestring(portal
.Title() + " : " + \
55 _("your registration has been accepted")()).replace('=\n', '')
56 , ContentType
= 'text/plain'
62 MailHost
.send( message
)
63 if portal
.getProperty('validate_email') :
64 rtool
.mailPassword(member
.getId(), context
.REQUEST
)