SendGrid simple async client based on httpx.
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async_sendgrid-0.0.4.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file async_sendgrid-0.0.4.tar.gz
.
File metadata
- Download URL: async_sendgrid-0.0.4.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d1a8d961a4eea300718168d500b3193973d79ed50f37d604ab92ac473180e77 |
|
MD5 | 5129350a9a2ba823dd0925f74ea843e3 |
|
BLAKE2b-256 | 80c5b8bb5a64ba24dba40a135fdc4f108a649489d7d6b812d06bbb074ec1b07d |
File details
Details for the file async_sendgrid-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: async_sendgrid-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f84357bb31e9552b714218ab11a00fee503a0b86c1151aa97a3a59ebebaab68 |
|
MD5 | a342042ba547acf4cfc3f9b961c0aaed |
|
BLAKE2b-256 | f092dd18cb793547ad21c380091a48a1224d728b0811dbdb48aec440d44c64dc |