Skip to content

Instantly share code, notes, and snippets.

@joastbg
Created August 6, 2016 03:03
Show Gist options
  • Save joastbg/0748d255d31530d98c0ec1798e34a4c1 to your computer and use it in GitHub Desktop.
Save joastbg/0748d255d31530d98c0ec1798e34a4c1 to your computer and use it in GitHub Desktop.
Sendgrid in Python
import sendgrid
import os
from sendgrid.helpers.mail import *
sg = sendgrid.SendGridAPIClient(apikey="...")
from_email = Email("joastbg@gmail.com")
to_email = Email("joastbg@gmail.com")
subject = "Please activate your ABC account"
content = Content("text/html", "<h1>Welcome to ABC</h1>Please click this <a href=\"http://www.abc.com/activate/32132112121\">link</a> to activate your account!")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment