26ba76beb4e1449737f0cdb86edc861a9216238d
1 ## Script (Python) "sendNotificationEmail"
2 ##bind container=container
6 ##bind subpath=traverse_subpath
10 from Products
.photoprint
.utils
import translate
11 _
= lambda msg
: translate(msg
, context
)
12 portal
= context
.portal_url
.getPortalObject()
14 mtool
= portal
.portal_membership
16 recipients
= sci
.kwargs
.get('recipients', [])
21 MailHost
= portal
.MailHost
22 from quopri
import encodestring
24 def encodeAdr(member
) :
25 name
= member
.getMemberFullName(nameBefore
=0)
26 email
= member
.getProperty('email')
27 qpName
= encodestring(name
).replace('=\n', '')
28 return '''"=?utf-8?q?%s?=" <%s>''' % (qpName
, email
)
33 sender
= mtool
.getAuthenticatedMember()
34 sender
= encodeAdr(sender
)
36 recipientsFormated
= map(encodeAdr
, mtool
.getMembers( recipients
))
37 mto
= ', '.join(recipientsFormated
)
41 subject
= sci
.kwargs
.get('subject', '')
45 pr(sci
.kwargs
.get('comment', ''))
49 trNumber
= sci
.kwargs
.get('tracking_number', '')
51 pr(_('Tracking number').encode('utf-8') + ' ' + trNumber
)
53 trUrl
= sci
.kwargs
.get('tracking_url', '')
55 pr(_('Tracking url').encode('utf-8') + ' ' + trUrl
)
57 body
= '\n'.join(body
)
61 message
= context
.echange_mail_template( From
= sender
63 , Subject
= "=?utf-8?q?%s?=" % encodestring(subject
).replace('=\n', '')
64 , ContentType
= 'text/plain'
70 MailHost
.send( message
.encode('utf-8') )