Skip to main content

Async-Sendgrid

SendGrid simple async client based on httpx.

Installation

pip install async-sendgrid

Usage

import async_sendgrid
from sendgrid.helpers.mail import Content, Email, Mail, To
import os

API_KEY = os.environ.get('API_KEY')

from_email = Email("test@example.com")
to_email = To("test@example.com")
subject = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
content = Content("text/plain", "Sed varius ligula ac urna vehicula ultrices. Nunc ut dolor sem.")
mail = Mail(from_email, to_email, subject, content)

data = {
    "personalizations": [
        {
            "to": [{"email": "test@example.com"}],
            "subject": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
        }
    ],
    "from": {"email": "test@example.com"},
    "content": [
        {
            "type": "text/plain",
            "value": "Sed varius ligula ac urna vehicula ultrices. Nunc ut dolor sem."
        }
    ],
}


# Send email with context manager

async with async_sendgrid.AsyncClient(api_key=API_KEY) as client:
    response1 = await client.send(data)
    response2 = await client.send(mail)

# Send email without context manager

client = async_sendgrid.AsyncClient(api_key=API_KEY)
await client.open()
response1 = await client.send(data)
response2 = await client.send(mail)
await client.close()

Metadata

Release files for async-sendgrid 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for async-sendgrid 0.0.3
File Size Uploaded
async-sendgrid-0.0.3.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for async-sendgrid 0.0.3
File Interpreter ABI Platform
async_sendgrid-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / async-sendgrid-0.0.3.tar.gz

Download URL async-sendgrid-0.0.3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3ae1318a5ca3deeccc45bb71b7b79bf9579c90bd63699a2d83ae8af5766303ca
BLAKE2b-256 checksum
How to use checksums
03c83f0b8befaa08f9d4b42e8cb10d12af9071573553346df4717daee60efba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / async_sendgrid-0.0.3-py3-none-any.whl

Download URL async_sendgrid-0.0.3-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b342d287ba7a170bf9e6cf703d57c749ac9a6c7b1664d7cb8d1bcfaf4f1ce350
BLAKE2b-256 checksum
How to use checksums
cdbb0276d9791d44d0f23078d0c15617063a697741fd236029f88762be5c42e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release history Release notifications | RSS feed

0.0.4

2 release files

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page