Created
October 2, 2017 03:14
-
-
Save popowa/950a8d70aef47ad3157ab06c76aeafcc to your computer and use it in GitHub Desktop.
sample code test for sendgrid
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
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