是什么引起SMTPAuthenticationError

时间:2019-07-16 22:00:52

标签: django smtp gmail

我刚刚将应用程序部署到ubuntu服务器上。我有ssl,因此我在settings.py中进行了相应的修改,如下所示:

Traceback (most recent call last):
  File "/home/admin/Mefid/TransversalScripts/comunication.py", line 122, 
in send_email
    fail_silently=False, html_message=html_message)
  File "/home/admin/Mefid/venv2/lib/python3.7/site- 
packages/django/core/mail/__init__.py", line 60, in send_mail
return mail.send()
File "/home/admin/Mefid/venv2/lib/python3.7/site- 
packages/django/core/mail/message.py", line 291, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/admin/Mefid/venv2/lib/python3.7/site- packages/django/core/mail/backends/smtp.py", line 103, in send_messages
new_conn_created = self.open()
  File "/home/admin/Mefid/venv2/lib/python3.7/site-packages/django_smtp_ssl.py", line 14, in open
self.connection.login(self.username, self.password)
  File "/usr/lib/python3.7/smtplib.py", line 730, in login
raise last_exception
  File "/usr/lib/python3.7/smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
File "/usr/lib/python3.7/smtplib.py", line 642, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbvc\n5.7.14 YlL_uB0GK_TLI557gRMyVYqHRr9iVrfj5mJ3jaEuyHjSmmevxT5-8ocIMMRh0BVOPqnrCR\n5.7.14 prX-jJCduiyPcF2RrYAWJkg4A5jUboKUMLzBEyz72VWQLPYiOKxFcZ5SBvrICb> Please\n5.7.14 log in via your web browser and then try again.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 i11sm7651758oia.9 - gsmtp')

我相信这是正确的配置,但是当发送电子邮件时,我会收到类似的信息

int

'''

我在这里遵循了https://github.com/bancek/django-smtp-ssl的指南,还有什么我需要注意的吗?感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

确保您已打开对Google帐户的应用访问权限较少

转到您的Google帐户设置,找到安全性->帐户权限->访问不太安全的应用,启用此选项。

关于此选项:https://support.google.com/accounts/answer/6010255