How do you configure Django and Postfix to send emails for Django apps?
I am able to do it using Gmail server settings but I want to send email from my own server using my own domain.
How do you configure Django and Postfix to send emails for Django apps?
I am able to do it using Gmail server settings but I want to send email from my own server using my own domain.
I banged my head a lot before realizing that it is actually quite simple:
add this to your settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'Whatever <[email protected]>'
Also make sure that a fully qualified domain name (say mybox.example.com) is set up on your server (how),
Then you need to have these lines in your /etc/postfix/main.cf:
myhostname = mybox.example.com
mydestination = localhost.server.com, localhost, example.com
Also you have to set up proper MX record for your domain (check here) in your dns server (and in your registrar, if you handle dns lookup through you them)
© 2022 - 2024 — McMap. All rights reserved.
telnet localhost 25
on the machine to see if you get a response. If you get a response that looks like220 hostname.local ESMTP Postfix
then it's on. Type quit, and check the mail queue by typingmailq
. This will show you if your messages aren't being delivered. The reasoning will be in the maillog, usually/var/log/maillog
. – Auric