import smtplib
from email.mime.text import MIMEText
from email.header import Header
#要发送的邮箱用户名/密码
smtpserver = 'smtp.163.com'
user = 'zhangmengping11@163.com'
password = '******授权码'
#发送的邮箱
sender = 'zhangmengping11@163.com'
#接收的邮箱
receiver = 'amber.zhang@joymed-tech.com'
#发送邮箱主题
subject = 'Python SMTP 邮件测试'
#编写HTML类型的邮件正文
msg = MIMEText('<html><h1>大佬好!</h1></html>','html','utf-8')
msg['Subject'] = Header(subject,'utf-8')
msg['from'] = 'zhangmengping11@163.com'
msg['to'] = 'amber.zhang@joymed-tech.com'
#连接发送邮件
smtp = smtplib.SMTP()
smtp.connect(smtpserver)
smtp.login(user,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()
Python发送邮件代码存放
最新推荐文章于 2023-11-09 17:08:04 发布