SendGrid

6.12.5 · maintenance · verified Sun Mar 01

Official Python SDK for the Twilio SendGrid Email API v3. Owned by Twilio. Two send patterns exist: Mail helper class and raw dict. v6.x is a breaking change from v5.x. Free plan retired May 2025. SDK last meaningfully updated Sep 2025 — in maintenance mode.

Warnings

Install

Imports

Quickstart

202 Accepted means queued for delivery, not delivered. The from_email must be a verified sender or from a verified domain.

import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail

message = Mail(
    from_email='sender@example.com',
    to_emails='recipient@example.com',
    subject='Sending with SendGrid',
    html_content='<strong>Hello from Python!</strong>'
)

try:
    sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
    response = sg.send(message)
    print(response.status_code)  # 202 = accepted
except Exception as e:
    print(str(e))

view raw JSON →