Mail utilities¶
-
render_to_email
(email, template[, data][, request][, from_email][, attachment])¶ Renders
template
with context constructed with help ofrequest
and filled withdata
, then sends it toemail
. An email template could contain email headers:from handy.mail import render_to_email def approve(...): article = ... render_to_email(article.author.email, 'approved.html', {'article': article})
in approved.html:
Content-Type: text/html Subject: Your article «{{ article.title }}» approved Hello, {{ article.author.username }}!<br><br> ....
-
mail_admins
(subject, message='', trace=True)¶ Send an email to admins, optionally appends stack trace to message. Handy when you want get an exception email but still serve user request.