【问题标题】:google SMTP is giving error on sending mail谷歌 SMTP 在发送邮件时出错
【发布时间】:2020-01-13 10:23:10
【问题描述】:

当用户登录并使用 django.core.mail(send mail) 时,我正在使用 python Django 向用户发送邮件,但它正在本地主机上工作并成功向用户发送电子邮件,但是当我在 Heroku 上托管我的网站时,它正在给一些错误。

settings.py

# email config
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'  # During deployment only
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = 587
EMAIL_HOST_USER = config('EMAIL_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_USER_PASSWORD')
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Masjid Matrimonial Team <noreply@example.com>'

Views.py

currenttime=datetime.now()
subject = "New Login Alert"
message="You have loged into your account on "+ currenttime.strftime('%A %d %B,%Y %I:%M %p')
recipient_list = [useris.appuser.email]
send_mail( subject, message, email_from, recipient_list )email_from = settings.EMAIL_HOST_USER

【问题讨论】:

标签: python django gmail email


【解决方案1】:

SMTP 错误代码 534 5.7.14 表示授权错误。

尝试通过https://myaccount.google.com/lesssecureapps通过不太安全的应用程序激活发送

【讨论】:

猜你喜欢
  • 2015-03-05
  • 2016-08-25
  • 1970-01-01
  • 2015-02-21
  • 1970-01-01
  • 2017-08-25
  • 2014-01-04
  • 2012-07-28
相关资源
最近更新 更多