python QQ 发送邮件功能
直接上代码备忘
import smtplib from email.mime.text import MIMEText from email.header import Header from email.mime.multipart import MIMEMultipart def send_email(): msg_from = '11111111@qq.com' # 发送方邮箱 passwd = ' 1111111111111' # 就是上面的授权码 to = ['xxxxxxxxxxxxxx'] # 接受方邮箱 msg = MIMEMultipart() conntent = "10.0.0.21 爬虫服务异常,请检查" msg.attach(MIMEText(conntent, 'plain', 'utf-8')) msg['Subject'] = "20.0.0.11爬虫异常" msg['From'] = msg_from s = smtplib.SMTP_SSL("smtp.qq.com", 465) s.login(msg_from, passwd) s.sendmail(msg_from, to, msg.as_string())
如果觉得对您有帮助,麻烦您点一下推荐,谢谢!
好记忆不如烂笔头
好记忆不如烂笔头