如何配置Django通过Postfix发送邮件? [英] How do you configure Django to send mail through Postfix?

查看:137
本文介绍了如何配置Django通过Postfix发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Django和Postfix配置为Django应用程序发送电子邮件?



我可以使用Gmail服务器设置,但是我想从我的自己的服务器使用我自己的域名。

解决方案

我意识到这实际上很简单: >

将此添加到您的 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@example.com>'

还要确保在您的服务器上设置完全合格的域名(如mybox.example.com)(如何



然后,您需要在 /etc/postfix/main.cf 中添加以下行:

  myhostname = mybox.example.com 
mydestination = localhost.server.com,localhost,example.com

此外,您还必须为您的域设置适当的MX记录(请参阅 here )在您的dns服务器(以及您的注册商,如果您通过他们处理dns查找)


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 <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)

这篇关于如何配置Django通过Postfix发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆