Skip to contentSkip to navigationSkip to topbar
On this page

v2 API Python Code Example


(warning)

This documentation is for the SendGrid Web API v2

We will deprecate this version on February 10, 2025. To access all the latest features and upcoming developments, please see our v3 API. For assistance with transitioning, refer to our migration guide.

(information)
(information)

Info

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(link takes you to an external page).


Using SendGrid's Python Library

using-sendgrids-python-library page anchor
1
# using SendGrid's Python Library
2
# https://github.com/sendgrid/sendgrid-python
3
import sendgrid
4
5
client = sendgrid.SendGridClient("SENDGRID_APIKEY")
6
message = sendgrid.Mail()
7
8
message.add_to("test@sendgrid.com")
9
message.set_from("you@youremail.com")
10
message.set_subject("Sending with SendGrid is Fun")
11
message.set_html("and easy to do anywhere, even with Python")
12
13
client.send(message)

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.