wiki:DeveloperGuidelines/Messaging/Channels/Email

Version 2 (modified by Fran Boon, 8 years ago) ( diff )

--

Email Channel

The Web2Py framework has a Mail class (defined in gluon/tools.py) which we make use of within Eden.

We configure this through settings in our Templates.

These settings are then read in {{models/00_settings.py}}:

sender = settings.get_mail_sender()
if sender:
    mail.settings.sender = sender
    mail.settings.server = settings.get_mail_server()
    mail.settings.tls = settings.get_mail_server_tls()
    mail_server_login = settings.get_mail_server_login()
    if mail_server_login:
        mail.settings.login = mail_server_login
    # Email settings for registration verification and approval
    _settings.mailer = mail

We wrap this within our Messaging module (modules/s3/s3msg.py) & so send mails using:

msg.send_email(to,
               subject,
               message,
               attachments=None,
               cc=None,
               bcc=None,
               reply_to=None,
               sender="%(sender)s",
               encoding="utf-8")

Notes

Can send emails with dynamic data inserted into templates (like HTML pages):

Note: See TracWiki for help on using the wiki.