Skip to content

Instantly share code, notes, and snippets.

@vivekn
Created October 15, 2011 10:00
Show Gist options
  • Save vivekn/1289350 to your computer and use it in GitHub Desktop.
Save vivekn/1289350 to your computer and use it in GitHub Desktop.
Sendgrid example
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