Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server = smtplib.SMTP_SSL('smtp.mail.ru', 465)
- server.login(fromaddr, mypass)
- def send_mail(toaddr, subjectText, bodyText, filesToAttach=[]):
- msg = MIMEMultipart()
- msg['From'] = fromaddr
- msg['To'] = toaddr
- msg['Subject'] = subjectText
- body = bodyText
- msg.attach(MIMEText(body, 'plain'))
- files=filesToAttach
- for f in files or []:
- with open(f, "rb") as fil:
- part = MIMEApplication(
- fil.read(),
- Name=basename(f)
- )
- part['Content-Disposition'] = 'attachment; filename="%s"' % basename(f)
- msg.attach(part)
- text = msg.as_string()
- server.sendmail(fromaddr, toaddr, text)
- server.quit()
Add Comment
Please, Sign In to add comment