import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = '[email protected]'
password = 'fuck'
receivers = ["[email protected]", "[email protected]", "[email protected]"]
mail_msg = """
<p>Python 邮件发送测试...</p>
<p><a href="http://www.baidu.com">百度一下你就知道</a></p>
"""
message = MIMEText(mail_msg, 'html', 'utf-8')
message['Subject'] = '开门,劳资是HTML邮件'
message['From'] = sender
message['To'] = ';'.join(receivers)
try:
smtpObj = smtplib.SMTP_SSL()
smtpObj.connect('smtp.qq.com', 465)
smtpObj.login(sender, password)
smtpObj.sendmail(sender, receivers, message.as_string())
smtpObj.quit()
print("邮件发送成功")
except smtplib.SMTPException as e:
print("Error: 无法发送邮件", e)