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()
评论列表
文章目录