标签:href 发件人 邮件发送 import style receiver receive 接收 点击
import smtplib
from email.mine.text import MIMEText
from email.header import Header
# 邮件内容
mail_msg = ‘‘‘
<h2 style="color:#f00">这是一封自动发送的邮件</h2>
<p><a href="http://www.baidu.com">点击这里有好玩的哈哈哈哈</a><p>
‘‘‘
message = MIMEText(mail_msg, "html", "utf-8")
# 发件人名字,可以自由填写
message["From"] = Header("蚂蚁学Python", "utf-8")
# 收件人名字,可以自由填写
message["To"] = Header("葫芦娃大战蝙蝠侠", "utf-8")
# 邮件标题
subject = "Python自动发来的邮件"
message["Subject"] = Header(subject, "utf-8")
# 发送方
sender = "xxxxx@qq.com"
# 接收方,可以多个
receivers = ["xxxx@qq.com", ""]
# 使用QQ邮箱的服务,发送邮件
smtpObj = smtplib.SMTP_SSL("smtp.qq.com", 465)
smtpObj.login(sender, "password")
smtpObj.sendmail(sender, receivers, message.as_string())
smtpObj.quit()
print("邮件发送成功")
password获取:
登录发件方的qq邮箱
设置-账户-POP3开启服务-生成授权码
标签:href 发件人 邮件发送 import style receiver receive 接收 点击
原文地址:https://www.cnblogs.com/echonick/p/13151586.html