emmail.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:jiekou-python3 作者: liwanlei 项目源码 文件源码
def sendemali(filepath): #??email
    from_addr,password,mail_to,mail_body=load_emil_setting()
    msg = MIMEMultipart()
    msg['Subject'] = '?????????'    
    msg['From'] ='???????'
    msg['To'] = mail_to
    msg['Date'] = time.strftime('%a, %d %b %Y %H:%M:%S %z')
    att = MIMEText(open(r'%s'%filepath, 'rb').read(), 'base64', 'utf-8')
    att["Content-Type"] = 'application/octet-stream'  
    att["Content-Disposition"] = 'attachment; filename="pyresult.html"'  
    txt = MIMEText("???????????????",'plain','gb2312')     
    msg.attach(txt)
    msg.attach(att)
    smtp = smtplib.SMTP()
    server = smtplib.SMTP_SSL("smtp.qq.com",465)
    server.login(from_addr, password)
    server.sendmail(from_addr, mail_to, msg.as_string())
    server.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号