DEV Community

Discussion on: Send emails with Django and Gmail , a better way

Collapse
jeroen1205 profile image
Jeroen Jacobs

I do it a bit differently: I run PostFix on my servers, which is configured to use an external SMTP server as forwarder (can be GMail, SES, ...). Then I let my app deliver to my local SMTP server.

This has a few advantages:

  • App is no longer coupled to GMail settings
  • The most important one: mails will be queued on local server, in case remote SMTP goes down or is not available. Most SMTP servers already handle automatic retries, and dead mail queues out of the box.

If you do it within the Django app, I would suggest to add some message queue stuff (Celery) so SMTP calls don't block your app, or retry in case of failure.

Collapse
abderrahmanemustapha profile image
Toumi Abderrahmane Author

that's great thank you will try to implement this