space-accessstablestagetest-hooks
|
Last change
on this file since 191ec87 was
55ffcd1,
checked in by Alex Dehnert <adehnert@…>, 14 years ago
|
|
Add function to make email-sending easier
|
-
Property mode set to
100644
|
|
File size:
529 bytes
|
| 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='asa-db@mit.edu', ): |
|---|
| 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.