Django 1.8 & Gmail - SMTPAuthenticationError 用户名和密码不被接受
Django 1.8 & Gmail - SMTPAuthenticationError Username and Password not accepted
我真的不确定我做错了什么。
设置:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'email_address@gmail.com'
EMAIL_HOST_PASSWORD = '**********'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
在python manage.py shell
中:
import django
from django.conf import settings
from django.core.mail import send_mail
send_mail('test', 'content', settings.EMAIL_HOST_USER, ['myemail@gmail.com'], fail_silently=False)
我收到以下错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python34\lib\site-packages\django\core\mail\__init__.py", line 62, in send_mail
return mail.send()
File "C:\Python34\lib\site-packages\django\core\mail\message.py", line 303, in send
return self.get_connection(fail_silently).send_messages([self])
File "C:\Python34\lib\site-packages\django\core\mail\backends\smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "C:\Python34\lib\site-packages\django\core\mail\backends\smtp.py", line 67, in open
self.connection.login(self.username, self.password)
File "C:\Python34\lib\smtplib.py", line 652, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/answer/14257by17sm25608295wib.18 - gsmtp')
- 我试过了http://www.google.com/accounts/DisplayUnlockCaptcha。
- 我已经设置为allow less secure apps access。
- Google 认为密码是安全的。
- 未启用 2 步验证。
我是不是漏掉了什么?
我自己的错误。我的问题中的上述所有步骤都是正确的。
我 运行 from django.conf import settings
,更改了文件本身中的 username/password 详细信息,然后再次导入 settings
,认为更改会在之前的导入中导入。他们不是。使用新的 shell 成功了!
我真的不确定我做错了什么。
设置:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'email_address@gmail.com'
EMAIL_HOST_PASSWORD = '**********'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
在python manage.py shell
中:
import django
from django.conf import settings
from django.core.mail import send_mail
send_mail('test', 'content', settings.EMAIL_HOST_USER, ['myemail@gmail.com'], fail_silently=False)
我收到以下错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python34\lib\site-packages\django\core\mail\__init__.py", line 62, in send_mail
return mail.send()
File "C:\Python34\lib\site-packages\django\core\mail\message.py", line 303, in send
return self.get_connection(fail_silently).send_messages([self])
File "C:\Python34\lib\site-packages\django\core\mail\backends\smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "C:\Python34\lib\site-packages\django\core\mail\backends\smtp.py", line 67, in open
self.connection.login(self.username, self.password)
File "C:\Python34\lib\smtplib.py", line 652, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/answer/14257by17sm25608295wib.18 - gsmtp')
- 我试过了http://www.google.com/accounts/DisplayUnlockCaptcha。
- 我已经设置为allow less secure apps access。
- Google 认为密码是安全的。
- 未启用 2 步验证。
我是不是漏掉了什么?
我自己的错误。我的问题中的上述所有步骤都是正确的。
我 运行 from django.conf import settings
,更改了文件本身中的 username/password 详细信息,然后再次导入 settings
,认为更改会在之前的导入中导入。他们不是。使用新的 shell 成功了!