mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-30 01:20:08 -06:00
23 lines
693 B
Python
23 lines
693 B
Python
from django.core.mail import EmailMultiAlternatives
|
|
from django.template.loader import get_template
|
|
|
|
|
|
def send_rendered_email(subject, base_template_name, recipient_list, context=None):
|
|
if context is None:
|
|
context = {}
|
|
|
|
html_content = get_template(base_template_name + ".html").render(context)
|
|
text_content = get_template(base_template_name + ".txt").render(context)
|
|
|
|
# Configure and send an EmailMultiAlternatives
|
|
msg = EmailMultiAlternatives(
|
|
subject=subject,
|
|
body=text_content,
|
|
from_email=None, # this is settings.DEFAULT_FROM_EMAIL
|
|
to=recipient_list,
|
|
)
|
|
|
|
msg.attach_alternative(html_content, "text/html")
|
|
|
|
msg.send()
|