Ignore:
Timestamp:
27 Nov 2011, 18:55:06 (13 years ago)
Author:
Henrik Bettermann
Message:

Reorganise contact form pages. Use megrok.layout.Form.

File:
1 edited

Legend:

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

    r7196 r7225  
    2323import shutil
    2424import grok
     25import smtplib
     26from email.mime.text import MIMEText
    2527from cStringIO import StringIO
    2628from docutils.core import publish_string
     
    479481    return account
    480482
     483def 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
     488User Id: %s
     489Portal: %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.