duan2891 2018-10-09 12:52
浏览 589

Gmail SMTP身份验证始终失败

I created this software in python 3

import smtplib
TO = 'anywhere@mail.com'
SUBJECT = 'Text subject of the mail'
TEXT = 'Text of the mail'

gmail_sender = 'yourMail@gmail.com'
gmail_passwd = 'password'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(gmail_sender, gmail_passwd)
BODY = '
'.join(['To: %s' % TO,
                    'From: %s' % gmail_sender,
                    'Subject: %s' % SUBJECT,
                    '', TEXT])
try:
    server.sendmail(gmail_sender, [TO], BODY)
    print ('email sent')
except:
    print ('error sending mail')
server.quit()

The first day the software worked well but now I always have an authentification error from gmail :

   smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at
5.7.8  https://support.google.com/mail/?p=BadCredentials o81-v6sm9180362wmo.38 - gsmtp')

What I did already is :

I desactivated the unlock captchar from this link :

https://accounts.google.com/DisplayUnlockCaptcha

and I have enabled the less secure apps from this link:

https://www.google.com/settings/security/lesssecureapps

But still the same, I can't send an e-mail anymore. It doesn't seems that there's a Python software problem because I wrote the same software in Go and I still receive the same error.

  • 写回答

1条回答 默认 最新

  • doujiangao4229 2018-10-09 18:08
    关注

    It’s solved. My login was wrong.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 被蓝屏搞吐了,有偿求帮解答,Ai回复直接拉黑
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并