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())

 

posted @ 2021-04-02 11:07  淋哥  阅读(83)  评论(0编辑  收藏  举报