EmailUtils.py 文件源码

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

项目:WebAutomaiton 作者: AlvinXuCH 项目源码 文件源码
def send_email(send_from,send_to,subject,text,files=None,server="10.210.41.203"):

    #assert(isinstance(send_to,list),"Send To email should be a list")

    msg = MIMEMultipart()
    msg['From'] = send_from
    msg['To'] = send_to
    msg['Date'] = formatdate(localtime = True)
    msg['Subject'] = subject

    msg.attach(MIMEText(text,'html'))

    with open(files,"rb") as f:
        part = MIMEApplication(f.read(),Name=basename(files))
        msg.attach(part)
    smtp = smtplib.SMTP(server,0)
    smtp.sendmail(send_from,send_to,msg.as_string())
    smtp.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号