Changes between Initial Version and Version 1 of DeveloperGuidelines/Messaging/Channels/Email


Ignore:
Timestamp:
06/05/13 15:09:03 (12 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Messaging/Channels/Email

    v1 v1  
     1= Email Channel =
     2
     3The Web2Py framework has a Mail class (defined in {{{gluon/tools.py}}}) which we make use of within Eden.
     4
     5We configure this through settings in our [DeveloperGuidelines/Templates Templates].
     6
     7These settings are then read in {{models/00_settings.py}}:
     8{{{
     9sender = settings.get_mail_sender()
     10if sender:
     11    mail.settings.sender = sender
     12    mail.settings.server = settings.get_mail_server()
     13    mail.settings.tls = settings.get_mail_server_tls()
     14    mail_server_login = settings.get_mail_server_login()
     15    if mail_server_login:
     16        mail.settings.login = mail_server_login
     17    # Email settings for registration verification and approval
     18    _settings.mailer = mail
     19}}}
     20
     21We wrap this within our Messaging module (modules/s3/s3msg.py) & so send mails using:
     22msg.send_email(to,
     23               subject,
     24               message,
     25               attachments=None,
     26               cc=None,
     27               bcc=None,
     28               reply_to=None,
     29               sender="%(sender)s",
     30               encoding="utf-8")
     31
     32== Notes ==
     33Can send emails with dynamic data inserted into templates (like HTML pages):
     34 * http://groups.google.com/group/web2py/browse_thread/thread/f6c903f9c67cfe2e