This library allows you to quickly and easily use the SendGrid Web API via Python.
**NOTE: The /mail/send/beta endpoint is currently in beta!
Since this is not a general release, we do not recommend POSTing production level traffic through this endpoint or integrating your production servers with this endpoint.
When this endpoint is ready for general release, your code will require an update in order to use the official URI.
By using this endpoint, you accept that you may encounter bugs and that the endpoint may be taken down for maintenance at any time. We cannot guarantee the continued availability of this beta endpoint. We hope that you like this new endpoint and we appreciate any feedback that you can send our way.**
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.envgit clone -b v3beta --single-branch https://github.com/sendgrid/sendgrid-python.git
cd sendgrid-python
cp examples/helpers/mail/mail_example.py .- Update the to and from emails.
python mail_example.pygit clone -b v3beta --single-branch https://github.com/sendgrid/sendgrid-python.git- Check out the documentation for Web API v3 endpoints.
- Review the corresponding examples.
- From the root directory of this repo, use
from sendgrid import * - Check out the documentation for Web API v3 /mail/send/beta endpoint.
pip install sendgridor
easy_install sendgrid- The SendGrid Service, starting at the free level)
- Python-HTTP-Client
import sendgrid
from sendgrid.helpers.mail import *
from_email = Email("test@example.com")
subject = "Hello World from the SendGrid Python Library"
to_email = Email("test@example.com")
content = Content("text/plain", "some text here")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.beta.post(request_body=mail.get())
print(response.status_code)
print(response.response_body)
print(response.response_headers)import sendgrid
sg = sendgrid.SendGridAPIClient()
response = sg.client.api_keys.get()
print(response.status_code)
print(response.response_body)
print(response.response_headers)- SendGrid Docs
- v3 Web API
- 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://assets3.sendgrid.com/mkt/assets/logos_brands/small/sglogo_2015_blue-9c87423c2ff2ff393ebce1ab3bd018a4.png)