Django 1.8& Gmail - SMTPAuthenticationError不接受用户名和密码

时间:2015-08-19 11:47:08

标签: python django email gmail

我真的不确定我做错了什么。

设定:

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')

我收到以下错误:

METHOD_TYPES
---- ----------------
 ID   Methods_Type
---- ----------------
 1    public
 2    ALL_Methods
 3    private1235678
 4    social


METHOD_TABLE
-------- ----------------- ----------
 Ser_ID   Ser_Method_Type   Emp_Name
-------- ----------------- ----------
 1        (null)            AAAA
 2        (null)            BBBB
 3        All_Methods       Rama
 4        social            Raja
 5        private12345678   Rakesh

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

我自己的错误。我的问题中的所有上述步骤都是正确的。

我运行from django.conf import settings,更改了文件本身的用户名/密码详细信息,然后再次导入settings,认为更改将通过上一次导入导入。他们不是。使用新的shell工作了!