Mail¶
Ferris provides a couple of lightweight wrapper functions around the App Engine Mail API for sending emails.
- ferris.core.mail.send(recipient, subject, body, text_body=None, sender=None, reply_to=None, **kwargs)[source]¶
Sends an html email to recipient with the given subject and body.
If sender is none, it’s automatically set to app_config['email']['sender'].
If text_body is not specified, then body is used.
Any additionally arguments are passed to mail.send_mail, such as headers.
- ferris.core.mail.send_template(recipient, subject, template_name, context=None, theme=None, **kwargs)[source]¶
Renders a template and sends an email in the same way as send(). templates should be stored in /templates/email/<template>.html and /templates/email/<template>.txt. If the txt template is not specified, then the html one will be used for the “plaintext” body.
For example:
mail.send_template( recipient='jondoe@example.com', subject='A Test Email', template_name='test', context={ 'name': 'George' } )
Would render the template /templates/email/test.html and email the rendered html.