Changeset 7402
- Timestamp:
- 20 Dec 2011, 09:18:02 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7358 r7402 219 219 fullname = self.request.principal.title 220 220 try: 221 email _from= self.request.principal.email221 email = self.request.principal.email 222 222 except AttributeError: 223 email _from= self.config.email_admin223 email = self.config.email_admin 224 224 username = self.request.principal.id 225 225 usertype = getattr(self.request.principal, 226 226 'user_type', 'system').title() 227 body = data['body']228 email_to = self.config.email_admin229 subject = self.config.email_subject230 227 sirp_utils = getUtility(ISIRPUtils) 231 success = sirp_utils.sendMail(fullname,username,usertype, 232 self.config.name,body,email_from,email_to,subject) 228 success = sirp_utils.sendMail( 229 fullname,email, 230 self.config.name_admin,self.config.email_admin, 231 username,usertype,self.config.name, 232 data['body'],self.config.email_subject) 233 233 if success: 234 234 self.flash('Your message has been sent.') … … 246 246 @grok.action('Send now') 247 247 def send(self, *args, **data): 248 email_from = data['email_from']249 fullname = data['fullname']250 body = data['body']251 username = u'None'252 email_to = self.config.email_admin253 subject = self.config.email_subject254 usertype = u'Anonymous'255 248 sirp_utils = getUtility(ISIRPUtils) 256 success = sirp_utils.sendMail(fullname,username,usertype, 257 self.config.name,body,email_from,email_to,subject) 249 success = sirp_utils.sendMail( 250 data['fullname'],data['email_from'], 251 self.config.name_admin,self.config.email_admin, 252 u'None',u'Anonymous',self.config.name, 253 data['body'],self.config.email_subject) 258 254 if success: 259 255 self.flash('Your message has been sent.') … … 467 463 @grok.action('Send message now') 468 464 def send(self, *args, **data): 469 fullname = self.request.principal.title470 465 try: 471 email _from= self.request.principal.email466 email = self.request.principal.email 472 467 except AttributeError: 473 email_from = self.config.email_admin 474 username = self.request.principal.id 468 email = self.config.email_admin 475 469 usertype = getattr(self.request.principal, 476 470 'user_type', 'system').title() 477 body = data['body']478 email_to = self.context.email479 subject = self.config.email_subject480 471 sirp_utils = getUtility(ISIRPUtils) 481 success = sirp_utils.sendMail(fullname,username,usertype, 482 self.config.name,body,email_from,email_to,subject) 472 success = sirp_utils.sendMail( 473 self.request.principal.title,email, 474 self.context.title,self.context.email, 475 self.request.principal.id,usertype,self.config.name, 476 data['body'],self.config.email_subject) 483 477 if success: 484 478 self.flash('Your message has been sent.') -
main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py
r7400 r7402 28 28 from email.Utils import parseaddr, formataddr 29 29 30 def send_mail(from_name,from_ email,rcpt_name,rcpt_email,subject,body,config):30 def send_mail(from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config): 31 31 """ 32 32 XXX: While this method is unicode-proof (i.e. it can handle … … 37 37 38 38 header_charset = 'ISO-8859-1' 39 from_ = '%s <%s>' % (from_name,from_email)40 to_ = '%s <%s>' % (rcpt_name,rcpt_email)41 from_name, from_addr = parseaddr(from_)42 rcpt_name, rcpt_addr = parseaddr(to_)43 39 from_name = str(Header(unicode(from_name), header_charset)) 44 40 rcpt_name = str(Header(unicode(rcpt_name), header_charset)) … … 63 59 server.login(config.smtp_username,config.smtp_password) 64 60 try: 65 server.sendmail(from_ email,rcpt_email,msg.as_string())61 server.sendmail(from_addr,rcpt_addr,msg.as_string()) 66 62 except Exception, e: 67 63 # XXX: log error message … … 76 72 grok.implements(ISIRPUtils) 77 73 78 def sendMail(self,f ullname,username,usertype,portal,body,79 email_from,email_to,subject):74 def sendMail(self,from_name,from_addr,rcpt_name,rcpt_addr, 75 from_username,usertype,portal,body,subject): 80 76 """Send an email with data provided by forms. 81 77 """ … … 88 84 %s 89 85 """ 90 from_name = fullname 91 from_email = email_from 92 rcpt_name = 'xyz' 93 rcpt_email = email_to 94 body = text % (fullname,username,usertype,portal,body) 86 body = text % (from_name,from_username,usertype,portal,body) 95 87 return send_mail( 96 from_name,from_ email,rcpt_name,rcpt_email,subject,body,config)88 from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config) 97 89 98 90 def fullname(self,firstname,lastname,middlename=None): … … 139 131 config = grok.getSite()['configuration'] 140 132 from_name = config.name_admin 141 from_ email= config.email_admin133 from_addr = config.email_admin 142 134 rcpt_name = applicant.display_fullname 143 rcpt_ email= applicant.email135 rcpt_addr = applicant.email 144 136 body = text % ( 145 137 rcpt_name, msg,config.name,username,password,login_url) 146 138 return send_mail( 147 from_name,from_email,rcpt_name,rcpt_email,subject,body,config) 148 149 150 139 from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
Note: See TracChangeset for help on using the changeset viewer.