def sendEmailPrintable(textToSend,fileToSend,addressToSend, pathToFile, subject):
msg = MIMEMultipart()
msg['From'] = printableFromAddress
msg['To'] = addressToSend
msg['Subject'] = subject
msg.attach(MIMEText(textToSend,'plain'))
attachment = open(pathToFile+fileToSend, "rb")
part = MIMEBase('application','octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= %s" % fileToSend)
msg.attach(part)
server = smtplib.SMTP(emailServer, 25)
#server.starttls()
text = msg.as_string()
server.sendmail(printableFromAddress, addressToSend.split(","), text)
server.quit
attachment.close()
评论列表
文章目录