(to, subject, text, attach)
| 13 | |
| 14 | |
| 15 | def mail(to, subject, text, attach): |
| 16 | msg = MIMEMultipart() |
| 17 | |
| 18 | msg['From'] = gmail_user |
| 19 | msg['To'] = to |
| 20 | msg['Subject'] = subject |
| 21 | |
| 22 | msg.attach(MIMEText(text)) |
| 23 | |
| 24 | part = MIMEBase('application', 'octet-stream') |
| 25 | part.set_payload(open(attach, 'rb').read()) |
| 26 | Encoders.encode_base64(part) |
| 27 | part.add_header('Content-Disposition', |
| 28 | 'attachment; filename="%s"' % os.path.basename(attach)) |
| 29 | msg.attach(part) |
| 30 | |
| 31 | mailServer = smtplib.SMTP("smtp.gmail.com", 587) |
| 32 | mailServer.ehlo() |
| 33 | mailServer.starttls() |
| 34 | mailServer.ehlo() |
| 35 | mailServer.login(gmail_user, gmail_pwd) |
| 36 | mailServer.sendmail(gmail_user, to, msg.as_string()) |
| 37 | # Should be mailServer.quit(), but that crashes... |
| 38 | mailServer.close() |
| 39 | |
| 40 | |
| 41 | def Brow_ker_cont_optim(Vlist): |
no test coverage detected