Files
@ 3b2beedd4ac9
Branch filter:
Location: symposion_app/symposion/utils/mail.py - annotation
3b2beedd4ac9
983 B
text/x-python
Merge pull request #54 from faulteh/lca2017
Remove description, add fields to proposal for notification template
Remove description, add fields to proposal for notification template
db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 36ab6d599ffc db95cb618099 36ab6d599ffc db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 db95cb618099 11f697d13757 db95cb618099 36ab6d599ffc 11f697d13757 db95cb618099 36ab6d599ffc db95cb618099 073174e617b1 36ab6d599ffc 073174e617b1 db95cb618099 db95cb618099 | from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from django.contrib.sites.models import Site
def send_email(to, kind, **kwargs):
current_site = Site.objects.get_current()
ctx = {
"current_site": current_site,
"STATIC_URL": settings.STATIC_URL,
}
ctx.update(kwargs.get("context", {}))
subject = "[%s] %s" % (
current_site.name,
render_to_string("symposion/emails/%s/subject.txt" % kind, ctx).strip()
)
message_html = render_to_string("symposion/emails/%s/message.html" % kind, ctx)
message_plaintext = strip_tags(message_html)
from_email = settings.DEFAULT_FROM_EMAIL
bcc_email = settings.ENVELOPE_BCC_LIST
email = EmailMultiAlternatives(subject, message_plaintext, from_email, to, bcc=bcc_email)
email.attach_alternative(message_html, "text/html")
email.send()
|