Created
September 19, 2011 17:00
-
-
Save reorx/1226953 to your computer and use it in GitHub Desktop.
mail_threading
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
from django.core.mail import send_mail as core_send_mail | |
from django.core.mail import EmailMultiAlternatives | |
import threading | |
class EmailThread(threading.Thread): | |
def __init__(self, subject, body, from_email, recipient_list, fail_silently, html): | |
self.subject = subject | |
self.body = body | |
self.recipient_list = recipient_list | |
self.from_email = from_email | |
self.fail_silently = fail_silently | |
self.html = html | |
threading.Thread.__init__(self) | |
def run (self): | |
msg = EmailMultiAlternatives(self.subject, self.body, self.from_email, self.recipient_list) | |
if self.html: | |
msg.attach_alternative(self.html, "text/html") | |
msg.send(self.fail_silently) | |
def send_mail(subject, body, from_email, recipient_list, fail_silently=False, html=None, *args, **kwargs): | |
EmailThread(subject, body, from_email, recipient_list, fail_silently, html).start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment