我正在尝试使用python发送电子邮件(Gmail),但我收到以下错误.
Traceback (most recent call last):
File "emailSend.py", line 14, in <module>
server.login(username,password)
File "/usr/lib/python2.5/smtplib.py", line 554, in login
raise SMTPException("SMTP AUTH extension not supported by server.")
smtplib.SMTPException: SMTP AUTH extension not supported by server.
Run Code Online (Sandbox Code Playgroud)
Python脚本如下.
import smtplib
fromaddr = 'user_me@gmail.com'
toaddrs = 'user_you@gmail.com'
msg = 'Why,Oh why!'
username = 'user_me@gmail.com'
password = 'pwd'
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
Run Code Online (Sandbox Code Playgroud) 我有一个脚本,它会定期向收件人列表发送报告。一切正常,直到今天凌晨 4 点,当我检查我的收件箱时,报告没有出现。
通过调试代码:
import smtplib
username="my.user.account@gmail.com"
password="my.correct.password"
server=smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.ehlo()
server.login(username,password)
#if login worked, it should send a message, but it is not working, so I will suppress this part
server.quit()
Run Code Online (Sandbox Code Playgroud)
我收到以下(旧的)结果:
(250, b'smtp.gmail.com 为您服务, [SERVERIP]\nSIZE 35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8') (220, b'2.0.0 准备启动 TLS') ( , b'smtp.gmail.com 为您服务,[SERVERIP]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING 最近调用\nSMTPCHUNKFile\nSMTPCHUNKFile\n8BITMIME\n <pyshell#52>", line 6, in server.login(username,password) File "C:\Python\Python36\lib\smtplib.py", line 729, in login raise last_exception File "C:\Python\Python36 \lib\smtplib.py",第 720 行,在登录名 initial_response_ok=initial_response_ok) 文件“C:\Python\Python36\lib\smtplib.py”,第 641 行,在 auth 中引发 SMTPAuthenticationError(code, …
我已经有了用 python 发送电子邮件的代码:
\n\ndef send_email_gmail(subject, message, destination):\n """ Send an e-mail using gmail with message to destination email.\n\n Arguments:\n message {str} -- message string to send.\n destination {str} -- destination email (as string)\n """\n server = smtplib.SMTP(\'smtp.gmail.com\', 587)\n server.starttls()\n # not a real email account nor password, its all ok!\n server.login(\'me123@gmail.com\', \'fakepassword111!!!\')\n\n # craft message\n msg = EmailMessage()\n\n message = f\'{message}\\n\'\n msg.set_content(message)\n msg[\'Subject\'] = subject\n msg[\'From\'] = \'me123@gmail.com\'\n msg[\'To\'] = destination\n # send msg\n server.send_message(msg)\nRun Code Online (Sandbox Code Playgroud)\n\n我已经阅读了多个问题(使用 gmail 和 …