#coding=utf-8 import smtplib from email.mime.text import MIMEText from email.header import Header #服务器设置 mail_host = 'smtp.qq.com' #发送邮箱帐号 sender = '' #接收邮箱帐号 receiver = '' #发送邮箱帐号密码 user = '' password = 'xxxx' #需要到qq邮箱设置-账户开启pop3-生成暂时密码 #邮件主题 subject = 'python test' #正文 msg = MIMEText('你好','text','utf-8') #中文需参数'utf-8',单字节字符不需要 msg['Subject'] = Header(subject, 'utf-8') #Header()定义邮件标题,MIMEText()定义正文 #连接发送 smtp = smtplib.SMTP_SSL(mail_host, 465) smtp.login(user, password) smtp.sendmail(sender, receiver, msg.as_string()) smtp.quit()
python 脚本发邮件
猜你喜欢
转载自blog.csdn.net/qq_18525247/article/details/79818743
今日推荐
周排行