Created
August 30, 2019 10:04
-
-
Save jatinchauhann/4b9e35952ac4231255e0dd2e2318e5f3 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
def send_mail(franchise_name, send_from, send_to, subject, email_content, files, | |
server_host, server_port): | |
msg = MIMEMultipart() | |
msg['From'] = send_from | |
msg['To'] = send_to | |
msg['Date'] = formatdate(localtime=True) | |
msg['Subject'] = subject | |
msg.preamble = """ | |
Please open these reports using Google Chrome!""" | |
msg.attach(MIMEText(email_content, 'html')) | |
f = "{0} HDFS Stats.html".format(franchise_name) | |
part = MIMEApplication(files, Name=os.path.basename(f)) | |
part['Content-Disposition'] = 'attachment; filename="%s"' % os.path.basename(f) | |
msg.attach(part) | |
smtp = smtplib.SMTP(server_host, server_port) | |
smtp.starttls() | |
smtp.sendmail(send_from, send_to, msg.as_string()) | |
smtp.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment