Ignore:
Timestamp:
16 Dec 2011, 07:13:28 (13 years ago)
Author:
Henrik Bettermann
Message:

Seat up a global utility class to ease customization. Transform send_mail function into a utility method.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/utils
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py

    r7321 r7358  
    480480    account = authenticator.getAccount(principal_id)
    481481    return account
    482 
    483 def send_mail(fullname,username,usertype,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 User Type: %s
    490 Portal: %s
    491 
    492 %s
    493 """
    494     msg = MIMEText(text % (fullname,username,usertype,portal,body))
    495     msg['From'] = '%s <%s>' % (fullname,email_from)
    496     msg['To'] = email_to
    497     msg['Subject'] = subject
    498     server = smtplib.SMTP(config.smtp_server)
    499     if config.smtp_requires_login:
    500         server.login(config.smtp_username,config.smtp_password)
    501     try:
    502         server.sendmail(email_from,email_to,msg.as_string())
    503     except:
    504         return False
    505     server.quit()
    506     return True
Note: See TracChangeset for help on using the changeset viewer.