经测试有 QQ 邮箱
smtp.qq.com 465
smtp.163.com 465/994
smtp.qq.com 465
各种服务和配置方法都试了,例如其中的一种配置方法:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'zmrenwu@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
MAIL_USE_SSL = True
当然,不止以上一种配置,各种服务器,端口号即其排列组合都试了,注册了多个账号测试,账号绝对开启了SMTP/POP3等能开的服务都开了。
然而始终返回如下错误:
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
django 版本1.9.7,python 3.4
Just passed the test using qq mailbox, related configuration:
In
EMAIL_HOST_USER
这里填写的是你邮箱的用户名,是zmrenwu才对。然后在设置加入EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'。另外,在调试模式可以使用
MAIL_USE_TLS=True
, and bind port 587.I remember
MAIL_USE_SSL
这个应该是EMAIL_USE_SSL
right?And sometimes you can try other networks to test. . . It feels like it’s more of a network problem
gmail is banned!
All major domestic mailboxes are accepted.
There is a problem with your configuration, at least ensure the following principles:
Use TLS
Fill in username and password
Enable smtp service on your email provider
The second thing to note is:
Don’t send emails too frequently
Reject spam
For local configuration, please refer to @mugbya’s answer
For email configuration, please refer to the email instructions