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.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async_sendgrid-0.0.4.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_sendgrid-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / async_sendgrid-0.0.4.tar.gz
| Download URL | async_sendgrid-0.0.4.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d1a8d961a4eea300718168d500b3193973d79ed50f37d604ab92ac473180e77
|
|
BLAKE2b-256 checksum How to use checksums |
80c5b8bb5a64ba24dba40a135fdc4f108a649489d7d6b812d06bbb074ec1b07d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|
Release files / async_sendgrid-0.0.4-py3-none-any.whl
| Download URL | async_sendgrid-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f84357bb31e9552b714218ab11a00fee503a0b86c1151aa97a3a59ebebaab68
|
|
BLAKE2b-256 checksum How to use checksums |
f092dd18cb793547ad21c380091a48a1224d728b0811dbdb48aec440d44c64dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.17
|