space-accessstablestage
Line | |
---|
1 | from django.core.mail import EmailMessage |
---|
2 | from django.template import Context, Template |
---|
3 | from django.template.loader import get_template |
---|
4 | |
---|
5 | def email_from_template(tmpl, context, |
---|
6 | subject, to=[], cc=[], from_email=None, ): |
---|
7 | tmpl_obj = get_template(tmpl) |
---|
8 | ctx = Context(context) |
---|
9 | body = tmpl_obj.render(ctx) |
---|
10 | email = EmailMessage( |
---|
11 | subject=subject, |
---|
12 | body=body, |
---|
13 | from_email=from_email, |
---|
14 | to=to, |
---|
15 | cc=cc, |
---|
16 | bcc=['asa-db-outgoing@mit.edu', ], |
---|
17 | ) |
---|
18 | return email |
---|
Note: See
TracBrowser
for help on using the repository browser.