Heroku上Django的SMTP身份验证错误 [英] SMTP Authentication Error with Django on Heroku
问题描述
我正在尝试使用gmail smtp服务器从django应用发送电子邮件.当我在本地服务器上运行应用程序时,将发送电子邮件.但是在heroku上使用它时出现SMTP身份验证错误.
I am trying to send emails from my django app using the the gmail smtp servers. The emails are being sent when I run the application on my local server. But I'm getting an SMTP Authentication Error while using it on heroku.
跟踪-链接
settings.py-
settings.py -
# Email configuration.
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '***************@gmail.com'
EMAIL_HOST_PASSWORD = '************'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '******************@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
我已经重新检查了帐户密码,还从我的Google帐户启用了对安全性较低的应用程序的访问权限.但是我仍然收到此错误.
And I have rechecked the account password, also I have enabled the access of less secure apps from my google account. But still I am getting this error.
推荐答案
尝试使用 sendgrid ,因为gmail smtp具有一些问题.我也无法使用gmail smtp.但是使用sendgrid可以完美地工作.而且这对于基本用途也是免费的.
Try using sendgrid, because gmail smtp has some problem. I too was unable to do using gmail smtp. But it worked perfectly using sendgrid. And this is also free for basic use.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'userpassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'asdf@example.com'
这篇关于Heroku上Django的SMTP身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!