赞
踩
在学习的过程中遇到一些问题:
改好之后运行以下代码即可:
import smtplib from email.mime.text import MIMEText from email.header import Header mail_host="smtp.163.com" #设置服务器 mail_user="tina_huanghui@163.com" #用户名 mail_pass="****" #授权码,注意不是邮箱登录密码,是上述设置的授权密码!!! sender = 'tina_huanghui@163.com' receivers = ['425845636@qq.com'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱 message = MIMEText('test', 'plain', 'utf-8') message['From'] = "tina_huanghui@163.com" message['To'] = "425845636@qq.com" subject = 'test email' message['Subject'] = Header(subject, 'utf-8') smtpObj = smtplib.SMTP() smtpObj.connect(mail_host, 25) smtpObj.set_debuglevel(1) smtpObj.login(mail_user,mail_pass) smtpObj.sendmail(sender, receivers, message.as_string()) print("邮件发送成功")
好了,问题解决了!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。