Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

v2 API Python Code Example


(information)

Info

We recommend using SendGrid Python, our client library, available on GitHub(link takes you to an external page), with full documentation.

(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

_13
# using SendGrid's Python Library
_13
# https://github.com/sendgrid/sendgrid-python
_13
import sendgrid
_13
_13
client = sendgrid.SendGridClient("SENDGRID_APIKEY")
_13
message = sendgrid.Mail()
_13
_13
message.add_to("test@sendgrid.com")
_13
message.set_from("you@youremail.com")
_13
message.set_subject("Sending with SendGrid is Fun")
_13
message.set_html("and easy to do anywhere, even with Python")
_13
_13
client.send(message)


Rate this page: