S
S
Sergey Alekseev2018-05-11 11:40:21
Django
Sergey Alekseev, 2018-05-11 11:40:21

Django, what's the easiest way to send an email asynchronously?

Good afternoon, is it possible to send a letter without saleri? If yes, how? With what library? Or post links to articles. Thanks in advance)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-05-11
@serj2000

The simplest is to run the mail sending function in a separate thread:

from threading import Thread
from django.core.mail import send_mail

Thread(target=send_mail, args=(subject, txt_msg_body, settings.DEFAULT_FROM_EMAIL, smtp_to),
       kwargs={'fail_silently': (not settings.DEBUG), 'html_message': html_msg_body}).start()

But there are no guarantees of sending and there is a danger of flooding the system with a large number of shipments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question