Created
July 30, 2016 15:09
-
-
Save aggarwalankush/57c9cf01d3c1ea3639532f2efc2782bb to your computer and use it in GitHub Desktop.
Email a file from horton
This file contains 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.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email import Encoders | |
EMAIL_FROM_MESSAGE = '[email protected]' | |
# comma delimeted string eg. '[email protected], [email protected], [email protected]' | |
EMAIL_TO_MESSAGE = ['[email protected]','[email protected]'] | |
EMAIL_SUBJECT='Subject' | |
msg ='' | |
msg = MIMEMultipart() | |
#msg['From'] = '%s' % EMAIL_FROM_MESSAGE | |
#msg['To'] = '%s' % EMAIL_TO_MESSAGE | |
part = MIMEBase('application', "octet-stream") | |
part.set_payload(open("resultDescribe.txt", "rb").read()) | |
Encoders.encode_base64(part) | |
part.add_header('Content-Disposition', 'attachment; filename="resultDescribe.txt"') | |
msg.attach(part) | |
msg['Subject'] = EMAIL_SUBJECT | |
s = smtplib.SMTP('localhost') | |
s.sendmail('%s' % EMAIL_FROM_MESSAGE, EMAIL_TO_MESSAGE, msg.as_string()) | |
s.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment