1 2 3 4 5 6 7 8 9 10 11 12 13 14
| import smtplib from email.mime.text import MIMEText mail_sender='发送方qq号@qq.com' mail_code='发送方授权码' mail_receivers='接收方qq号@qq.com' subject='测试Python发邮件' content='测试Python发邮件' msg=MIMEText(content,_charset='utf-8') msg['Subject']=subject msg['From']=mail_sender msg['To']=mail_receivers mail= smtplib.SMTP_SSL("smtp.qq.com", 465) mail.login(mail_sender, mail_code) mail.sendmail(mail_sender, mail_receivers, msg.as_string())
|