diff options
Diffstat (limited to 'forum/utils/email.py')
-rwxr-xr-x | forum/utils/email.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/forum/utils/email.py b/forum/utils/email.py index a6ea1087..dc712572 100755 --- a/forum/utils/email.py +++ b/forum/utils/email.py @@ -1,21 +1,21 @@ -from django.core.mail import send_mail, EmailMultiAlternatives
-from django.conf import settings
-from django.template import loader, Context
-from django.utils.html import strip_tags
-from threading import Thread
-
-def send_email(subject, recipients, template, context={}, sender=settings.DEFAULT_FROM_EMAIL, txt_template=None):
- context['settings'] = settings
- html_body = loader.get_template(template).render(Context(context))
-
- if txt_template is None:
- txt_body = strip_tags(html_body)
- else:
- txt_body = loader.get_template(txt_template).render(Context(context))
-
- msg = EmailMultiAlternatives(subject, txt_body, sender, recipients)
- msg.attach_alternative(html_body, "text/html")
-
- thread = Thread(target=EmailMultiAlternatives.send, args=[msg])
- thread.setDaemon(True)
- thread.start()
+from django.core.mail import send_mail, EmailMultiAlternatives +from django.conf import settings +from django.template import loader, Context +from django.utils.html import strip_tags +from threading import Thread + +def send_email(subject, recipients, template, context={}, sender=settings.DEFAULT_FROM_EMAIL, txt_template=None): + context['settings'] = settings + html_body = loader.get_template(template).render(Context(context)) + + if txt_template is None: + txt_body = strip_tags(html_body) + else: + txt_body = loader.get_template(txt_template).render(Context(context)) + + msg = EmailMultiAlternatives(subject, txt_body, sender, recipients) + msg.attach_alternative(html_body, "text/html") + + thread = Thread(target=EmailMultiAlternatives.send, args=[msg]) + thread.setDaemon(True) + thread.start() |