5
我想有Django的發送電子郵件,但我收到此錯誤:Django的電子郵件smtp.gmail SMTPAuthenticationError特定應用-534密碼所需
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Python/2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
return mail.send()
File "/Library/Python/2.7/site-packages/django/core/mail/message.py", line 286, in send
return self.get_connection(fail_silently).send_messages([self])
File "/Library/Python/2.7/site-packages/django/core/mail/backends/smtp.py", line 92, in send_messages
new_conn_created = self.open()
File "/Library/Python/2.7/site-packages/django/core/mail/backends/smtp.py", line 59, in open
self.connection.login(self.username, self.password)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 615, in login
raise SMTPAuthenticationError(code, resp)
SMTPAuthenticationError: (534, '5.7.9 Application-specific password required. Learn more at\n5.7.9 http://support.google.com/accounts/bin/answer.py?answer=185833 v14sm3323298pbs.11 - gsmtp')
鏈接建議我進行兩步驗證其我做了但仍然沒有結果。
在我的settings.py
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
我試圖在Django殼測試這一點,但得到了上面顯示的錯誤:
>>> from django.core.mail import send_mail
>>> from django.conf import settings
>>> sub = "sup man"
>>> msg = "char lisss"
>>> from_user = settings.EMAIL_HOST_USER
>>> to = ["[email protected]"]
>>> send_mail(sub,msg,from_user,to, fail_silently=False)
感謝您的建議,但它仍然無法正常工作=/ – Liondancer 2015-02-10 00:35:12
對不起,我沒有意識到您的帳戶啓用了2因素身份驗證。您是否執行了Google支持頁面上的所有步驟來生成應用程序密碼,然後更新您的「EMAIL_HOST_PASSWORD」以使用該密碼,而不是您的常規帳戶密碼?在此頁上:https://support.google.com/accounts/answer/185833請按照「如何生成應用程序密碼」標題下的步驟操作。生成後,您需要在配置中使用該密碼。 – Joseph 2015-02-10 14:52:44
不錯,它的工作!如果你更新你的答案,我會接受你的答案! – Liondancer 2015-02-10 20:05:03