Skip to content

Instantly share code, notes, and snippets.

@popowa
Created October 2, 2017 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popowa/950a8d70aef47ad3157ab06c76aeafcc to your computer and use it in GitHub Desktop.
Save popowa/950a8d70aef47ad3157ab06c76aeafcc to your computer and use it in GitHub Desktop.
sample code test for sendgrid
import time
import sendgrid
import os
from datadog import statsd
from sendgrid.helpers.mail import *
sq = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("")
subject = "Hello"
to_email = Email("")
content = Content("text/plain", "Hello, Email!")
mail = Mail(from_email, subject, to_email, content)
response = sq.client.mail.send.post(request_body=mail.get())
if response.status_code == 202:
statsd.increment('email.send')
statsd.histogram('email.send.time', time.time())
print(response.status_code)
print(response.body)
print(response.headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment