本文介绍了Django 1.8使用Gmail发送邮件SMTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试使用django中的smtp.gmail.com发送邮件1.8 settings.py conatins EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend' 结果, EMAIL_HOST = 'smtp.gmail.com' 结果, EMAIL_PORT = 465,点击 EMAIL_HOST_USER ='sarath4coding' EMAIL_HOST_PASSWORD ='*********' DEFAULT_EMAIL_FROM ='[email protected]' 从django.core导入邮件 mail.send_mail('subject','message','[email protected] ',['[email protected]']) 但是收到错误 追溯(最近的最后一次呼叫):文件< console>,第1行,< module> 文件/home/manager/dj1.8/local/lib/python2.7/site-packages/django/core/mail/__init__.py,第62行,send_mail 返回邮件。 send()文件/home/manager/dj1.8/local/lib/python2.7/site-packages/django/core/mail/message.py,第303行,发送返回self.get_connection(fail_silently).send_messages([自己])档/home/manager/dj1.8/local/lib/python2.7/site-packages/django/core/mail/backends/smtp py 为,线100,在send_messages new_conn_created = self.open()档 /home/manager/dj1.8/local/lib/python2.7/site-packages/django_smtp_ssl.py ,第14行,打开 self.connection.login(self.username,self.password)文件/usr/lib/python2.7/smtplib.py,第622行,登录 raise SMTPAuthenticationError(code,resp) SMTPAuthenticationError:(534,'5.7.14< https://accounts.google.com/ContinueSignIn?sarp = 1& scc = 1& plt = AKgnsbuze \5.7.14 2FDKQt2Dlo2vqFIvbr6DnBItwWvh9DChPwbeTZO66N91gzmiA437Vqs80cZ9-8u13vxq5a \5.7.14 bVahzO_BQcZ53yKbJ-YbAlmFE1XIK7MfH97O0wI1lvzpTG_WAHuTIBF0HD1GA2icUoUemt\\\5.7.14 ErZn4qb942aAIMG103FnrzLp4txXTbXC-wGLpaz5yvnUN5thahvv3-RiIVW8F1QddZKZlg\\\5.7.14 qQKpqWw56zr1AcO2s_oaBEt556fQ>请通过您的网络浏览器登录,然后再重新登录.\\\5.7.14了解更多信息,请参阅\"\5.7.14 https://support.google.com/mail/answer/78754 kx14sm6579665pab.0 - gsmtp ') 我尝试了文档中的所有内容,并遵循了许多建议的解决方案。 ,如 https://accounts.google.com/DisplayUnlockCaptcha ,启用低安全性应用等。 但仍然有错误 任何人都可以告诉,如何正确使用django1.8发送邮件使用Gmail 解决方案在 settings.py 中: EMAIL_USE_TLS =真 EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = '[email protected]' EMAIL_HOST_PASSWORD ='测试' EMAIL_PORT = 587 和 views.py from django.core.mail i mport EmailMessage email = EmailMessage('title','body',to = [email]) email.send() 和: https://accounts.google.com / DisplayUnlockCaptcha I was trying send a mail using smtp.gmail.com in django 1.8settings.py conatins EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend' EMAIL_HOST='smtp.gmail.com' EMAIL_PORT=465 EMAIL_HOST_USER = 'sarath4coding' EMAIL_HOST_PASSWORD = '*********' DEFAULT_EMAIL_FROM = '[email protected]'from django.core import mailmail.send_mail('subject','message','[email protected]',['[email protected]'])But got the error Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/manager/dj1.8/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail return mail.send() File "/home/manager/dj1.8/local/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send return self.get_connection(fail_silently).send_messages([self]) File "/home/manager/dj1.8/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages new_conn_created = self.open() File "/home/manager/dj1.8/local/lib/python2.7/site-packages/django_smtp_ssl.py", line 14, in open self.connection.login(self.username, self.password) File "/usr/lib/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp)SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbuze\n5.7.14 2FDKQt2Dlo2vqFIvbr6DnBItwWvh9DChPwbeTZO66N91gzmiA437Vqs80cZ9-8u13vxq5a\n5.7.14 bVahzO_BQcZ53yKbJ-YbAlmFE1XIK7MfH97O0wI1lvzpTG_WAHuTIBF0HD1GA2icUoUemt\n5.7.14 ErZn4qb942aAIMG103FnrzLp4txXTbXC-wGLpaz5yvnUN5thahvv3-RiIVW8F1QddZKZlg\n5.7.14 qQKpqWw56zr1AcO2s_oaBEt556fQ> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 kx14sm6579665pab.0 - gsmtp')I tried every thing the document says and followed many suggested solutions.like https://accounts.google.com/DisplayUnlockCaptcha, enabling low security apps etc.but still got errorsCan anybody tell, how to properly congigure django1.8 to send mail using Gmail. 解决方案 for me in settings.py:EMAIL_USE_TLS = TrueEMAIL_HOST = 'smtp.gmail.com'EMAIL_HOST_USER = '[email protected]'EMAIL_HOST_PASSWORD = 'test'EMAIL_PORT = 587and views.py:from django.core.mail import EmailMessageemail = EmailMessage('title', 'body', to=[email])email.send()and: https://accounts.google.com/DisplayUnlockCaptcha 这篇关于Django 1.8使用Gmail发送邮件SMTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 01:44