This library allows you to quickly and easily use the SendGrid Web API via Python.
BREAKING CHANGE as of 2016.06.14
Version 3.0.0
is a breaking change for the entire library.
Version 3.0.0 brings you full support for all Web API v3 endpoints. We have the following resources to get you started quickly:
Thank you for your continued support!
All updates to this library is documented in our CHANGELOG.
First, get your free SendGrid account here.
Next, update your environment with your SENDGRID_API_KEY.
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
pip install sendgrid
or
easy_install sendgrid
- The SendGrid Service, starting at the free level)
- Python-HTTP-Client
import sendgrid
import os
from sendgrid.helpers.mail import *
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("[email protected]")
subject = "Hello World from the SendGrid Python Library"
to_email = Email("[email protected]")
content = Content("text/plain", "some text here")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)
import sendgrid
import os
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
response = sg.client.api_keys.get()
print(response.status_code)
print(response.body)
print(response.headers)
- SendGrid Documentation
- Usage Documentation
- Example Code
- v3 Web API Mail Send Helper - build a request object payload for a v3 /mail/send API call.
If you are intersted in the future direction of this project, please take a look at our milestones. We would love to hear your feedback.
We encourage contribution to our libraries, please see our CONTRIBUTING guide for details.
Quick links:
sendgrid-python is guided and supported by the SendGrid Developer Experience Team.
sendgrid-python is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-python are trademarks of SendGrid, Inc.
![SendGrid Logo] (https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)