Last active
May 11, 2016 07:13
-
-
Save rishigb/970adf227ff415eb64a879ea142ca812 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import smtplib | |
| from email.mime.image import MIMEImage | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText | |
| from email.mime.base import MIMEBase | |
| from email import encoders | |
| fromaddr = "" | |
| toaddr = "" | |
| msg = MIMEMultipart() | |
| msg['From'] = fromaddr | |
| msg['To'] = toaddr | |
| msg['Subject'] = "System Generated Email" | |
| body = "PFA" | |
| msg.attach(MIMEText(body, 'plain')) | |
| filename = "" | |
| attachment = open("/path/to/file", "rb") | |
| part = MIMEBase('application', 'octet-stream') | |
| part.set_payload((attachment).read()) | |
| encoders.encode_base64(part) | |
| part.add_header('Content-Disposition', "attachment; filename= %s" % filename) | |
| msg.attach(part) | |
| server = smtplib.SMTP('smtp.mail.yahoo.com', 587) | |
| server.starttls() | |
| server.login(fromaddr, "ADD_PASSWORD_HERE") | |
| text = msg.as_string() | |
| server.sendmail(fromaddr, toaddr, text) | |
| server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment