前言
Python3发送邮件学习笔记
发送文本邮件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| host = "smtp.qq.com" port = 465 login_email = "[email protected]" login_password = "xxxxxxxxxxxxxxxx" send_from = "[email protected]" send_to = "[email protected]" email_title = "标题" email_content = "正文"
con = smtplib.SMTP_SSL(host, port)
con.login(login_email, login_password)
msg = MIMEMultipart() msg["Subject"] = Header(email_title, "utf-8").encode() msg["From"] = f"{send_from} <{send_from}>" msg["To"] = send_to
msg.attach(MIMEText(email_content, "plain", "utf-8"))
con.sendmail(send_from, send_to, msg.as_string())
con.quit()
|
完成
参考文献
CSDN——酒坛坛儿^_^
哔哩哔哩——Python编程语言