Changeset 7225 for main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py
- Timestamp:
- 27 Nov 2011, 18:55:06 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py
r7196 r7225 23 23 import shutil 24 24 import grok 25 import smtplib 26 from email.mime.text import MIMEText 25 27 from cStringIO import StringIO 26 28 from docutils.core import publish_string … … 479 481 return account 480 482 483 def send_mail(fullname,username,portal,body,email_from,email_to,subject): 484 """Send an email with data provided by forms. 485 """ 486 config = grok.getSite()['configuration'] 487 text = """Fullname: %s 488 User Id: %s 489 Portal: %s 490 491 %s 492 """ 493 msg = MIMEText(text % (fullname,username,portal,body)) 494 msg['From'] = '%s <%s>' % (fullname,email_from) 495 msg['To'] = email_to 496 msg['Subject'] = subject 497 server = smtplib.SMTP(config.smtp_server) 498 if config.smtp_requires_login: 499 server.login(config.smtp_username,config.smtp_password) 500 try: 501 server.sendmail(email_from,email_to,msg.as_string()) 502 except: 503 return False 504 server.quit() 505 return True
Note: See TracChangeset for help on using the changeset viewer.