v2 API Python Code Example
We recommend using SendGrid Python, our client library, available on GitHub, with full documentation.
The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see Continue Using V2 in Python.
Using SendGrid's Python Library
# using SendGrid's Python Library
# https://github.com/sendgrid/sendgrid-python
import sendgrid
client = sendgrid.SendGridClient("SENDGRID_APIKEY")
message = sendgrid.Mail()
message.add_to("test@sendgrid.com")
message.set_from("you@youremail.com")
message.set_subject("Sending with SendGrid is Fun")
message.set_html("and easy to do anywhere, even with Python")
client.send(message)
Need some help?
We all do sometimes. Get help now from the Twilio SendGrid Support Team.
Running into a coding hurdle? Lean on the wisdom of the crowd by browsing the SendGrid tag on Stack Overflow or visiting Twilio's Stack Overflow Collective.