相关疑难解决方法(0)

如何使用Python以Gmail作为提供商发送电子邮件?

我正在尝试使用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)

python email gmail smtp

272
推荐指数
10
解决办法
31万
查看次数

SMTPAuthenticationError 5.7.14 请通过您的网络浏览器登录\n5.7.14

我有一个脚本,它会定期向收件人列表发送报告。一切正常,直到今天凌晨 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 gmail smtplib

9
推荐指数
4
解决办法
1万
查看次数

如何从 python 不使用 gmail 发送电子邮件?

我已经有了用 python 发送电子邮件的代码:

\n\n
def 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)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我已经阅读了多个问题(使用 gmail 和 …

python email

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×3

email ×2

gmail ×2

smtp ×1

smtplib ×1