Skip to content

Instantly share code, notes, and snippets.

@aggarwalankush
Created July 30, 2016 15:09
Show Gist options
  • Save aggarwalankush/57c9cf01d3c1ea3639532f2efc2782bb to your computer and use it in GitHub Desktop.
Save aggarwalankush/57c9cf01d3c1ea3639532f2efc2782bb to your computer and use it in GitHub Desktop.
Email a file from horton
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email import Encoders
EMAIL_FROM_MESSAGE = 'pp_dt_risk_batch@paypal.com'
# comma delimeted string eg. 'a@paypal.com, b@paypal.com, c@paypal.com'
EMAIL_TO_MESSAGE = ['srinivmanoharan@paypal.com','annaggarwal@paypal.com']
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