Send Multi-Threaded E-mails
Here is a short easy code snippet for sending synchronous multi-threaded E-mails in Django without using any other extra libraries.
import threading
from django.core.mail import EmailMessage
from django.conf import settings
class EmailThread(threading.Thread):
def __init__(self, email_message):
self.email_message = email_message
threading.Thread.__init__(self)
def run(self):
print(self.email_message.send())
email_message = EmailMessage(
"subject",
"message",
settings.EMAIL_HOST_USER,
["example@mail.com"]
)
EmailThread(email_message).start()