-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.conf import settings | ||
from django.core.mail import send_mail | ||
from django.template.loader import render_to_string | ||
|
||
def send_email(subject, recipient_list, template_name, context): | ||
""" | ||
Send email via SMTP gateway through Django's email backend. | ||
""" | ||
# Load the template | ||
email_html_message = render_to_string(template_name, context) | ||
|
||
# Get the DEFAULT_FROM_EMAIL from settings | ||
default_from_email = getattr(settings, "DEFAULT_FROM_EMAIL") | ||
|
||
# Send the email | ||
send_mail( | ||
subject, | ||
'', # plain text content can be empty as we're sending HTML | ||
default_from_email, | ||
recipient_list, | ||
html_message=email_html_message | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters