how to send asynchronous email using django
it is ok now ;
import threading
from threading import Thread
class EmailThread(threading.Thread):
def __init__(self, subject, html_content, recipient_list):
self.subject = subject
self.recipient_list = recipient_list
self.html_content = html_content
threading.Thread.__init__(self)
def run (self):
msg = EmailMessage(self.subject, self.html_content, EMAIL_HOST_USER, self.recipient_list)
msg.content_subtype = "html"
msg.send()
def send_html_mail(subject, html_content, recipient_list):
EmailThread(subject, html_content, recipient_list).start()
In the long run, it may prove to be a good decision to use a third-party Django application, such as django-mailer, to handle all sorts of asynchronous email sending/management requirements.