[python] 从网易邮箱发送邮件到QQ邮箱

code 如下,可以成功发送邮件,(但是反过来发送没成功,yahoo 邮箱也是个例外)

import smtplib
from email.mime.text import MIMEText
from email.header import Header

msg = MIMEText('Hi, this is a mail sent by python, thanks, bye!', 'plain', 'utf-8')
msg['Subject'] = Header('Python SMTP 测试', 'utf-8').encode()
msg['from'] = "[email protected]"
msg['to'] = '[email protected]'

smtp = smtplib.SMTP()
smtp.connect("smtp.163.com", 25)
smtp.set_debuglevel(1)

smtp.login('account_163', 'password_163')
smtp.sendmail("[email protected]", '[email protected]', msg.as_string())
smtp.quit()
print("MAIL SENT SUCCESS")

猜你喜欢

转载自blog.csdn.net/ftell/article/details/80085660