How do you configure Django to send mail through Postfix? [closed]

假如想象 提交于 2019-12-17 22:37:10

问题


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.


回答1:


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 <whatever@example.com>'

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)



来源:https://stackoverflow.com/questions/26333009/how-do-you-configure-django-to-send-mail-through-postfix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!