[Answered ]-How speed up sending email in Django rest framework?

1👍

I think there are two things you need to consider:

1. You don’t want to make the api call wait to send email.

You should consider using celery together with this library django-celery-email as email backend. In this case sending an email will happen asynchronously (the actual email send will happen on a celery worker) and api call will not wait for it, thus api call will be faster.

Note that in this case you won’t be able to know when/if the email was delivered in the api view (since it will happen asynchronous), so keep that in mind. If you really need it, there are ways to find out by storing celery task results, check django-celery-results so you can query that table using celery task ids.

2. You want to send mass emails faster.

Have a look at django mass-email, this help sending multiple emails by using a single connection to the mail server. This works also if you use django-celery-email.

Leave a comment