python – 带smtp.gmail的Django电子邮件SMTPAuthenticationError 534需要
发布时间:2021-01-12 03:41:54 所属栏目:Python 来源:互联网
导读:我想让 django发送电子邮件,但我收到此错误: 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
我想让 django发送电子邮件,但我收到此错误: 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 atn5.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@gmail.com' EMAIL_HOST_PASSWORD = 'password' EMAIL_PORT = 587 我尝试在django shell中测试它,但得到上面显示的错误: >>> 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@email.com"] >>> send_mail(sub,msg,from_user,to,fail_silently=False) 解决方法由于您使用双因素身份验证,因此您必须为此应用程序创建密码才能访问您的Google帐户,而无需使用2因素身份验证.执行Google支持页面上的所有步骤以生成应用程序密码,然后更新您的EMAIL_HOST_PASSWORD以使用该密码,而不是您的常规帐户密码. 在此页面上:support.google.com/accounts/answer/185833按照“如何生成应用密码”标题下的步骤操作.生成后,您需要在配置中使用该密码. (编辑:百色站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 仅用50行代码实现一个Python编写的计算器的教程
- python – 迭代numpy数组列的所有成对组合
- python – ImportError:Elastic Beanstalk中没有名为djang
- django – MongoEngine _types和_cls字段
- 在包含f2py(最小工作示例)的模块中包含已编译的模块?
- python – 如何编写依赖于子关系中的列的混合属性?
- 即使在运行迁移后,Django Programming错误列也不存在
- python – pandas数据帧中的条件列算法
- python – boto dynamodb2:我可以只使用范围键查询表吗?
- 如何使用各种数据类型(int,tuple)展平列表