-
-
Save miskolc/cc4c551432f2124c0473f825f215d468 to your computer and use it in GitHub Desktop.
Python SMTP Mailer using Amazon SES (smtplib)
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 sys | |
import smtplib | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEText import MIMEText | |
name = "Ruan" | |
from_address = "[email protected]" | |
to_address = "[email protected]" | |
subject = "Test" | |
msg = MIMEMultipart() | |
msg['From'] = from_address | |
msg['To'] = to_address | |
msg['Subject'] = "Notification: {}".format(subject) | |
body = """ | |
Hello, {0}. | |
This is a plain email. | |
Kind Regards, | |
Me | |
""".format(name) | |
msg.attach(MIMEText(body, 'plain')) | |
server = smtplib.SMTP('email-smtp.eu-west-1.amazonaws.com', 587) | |
server.starttls() | |
server.login("USER", "PASS") | |
text = msg.as_string() | |
server.sendmail(from_address, to_address, text) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment