Created
October 15, 2011 10:00
-
-
Save vivekn/1289350 to your computer and use it in GitHub Desktop.
Sendgrid example
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
def sendgrid(from_email, to_email, subject, message): | |
msg = MIMEText(message) | |
msg['Subject'] = subject | |
msg['From'] = from_email | |
msg['To'] = to_email | |
# Login credentials to sendgrid | |
username = '**********' | |
password = "**********" | |
# Open a connection to the SendGrid mail server | |
s = smtplib.SMTP('smtp.sendgrid.net') | |
# Authenticate | |
s.login(username, password) | |
# sendmail function takes 3 arguments: sender's address, recipient's address | |
# and message to send - here it is sent as one string. | |
s.sendmail(from_email, to_email, msg.as_string()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment