1.发送文本邮件
import smtplib
from email.mime.text import MIMEText
con = smtplib.SMTP_SSL('smtp.qq.com',465)
print(con)
con.login(user='834628301@qq.com',password='xxx')
sender = '834628301@qq.com'
reciever = '834628301@qq.com'
htmlContent = "<a href='http://www.baidu.com'>我是html代码</a>"
message = MIMEText(htmlContent,'html','utf-8')
message['Subject'] = '发送给小幸运的一封信'
message['from'] = sender
message['to'] = reciever
try:
con.sendmail(sender,reciever,message.as_string())
print('邮件发送成功')
except Exception as e:
print('没有办法发送邮件,报错了'