Async SendGrid client based on httpx
Project description
aiosendgrid
A simple SendGrid asynchronous client based on httpx.
Installation
pip install aiosendgrid
Or, to include the optional SendGrid helpers support, use:
pip install aiosendgrid[helpers]
Usage
With Mail Helper Class
import aiosendgrid
from sendgrid.helpers.mail import Content, Email, Mail, To
SENDGRID_API_KEY = "SG.XXX"
from_email = Email("test@example.com")
to_email = To("test@example.com")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, to_email, subject, content)
async with aiosendgrid.AsyncSendGridClient(api_key=SENDGRID_API_KEY) as client:
response = await client.send_mail_v3(body=mail.get())
More info on sendgrid-python official repository.
Without Mail Helper Class
import aiosendgrid
SENDGRID_API_KEY = "SG.XXX"
data = {
"personalizations": [
{
"to": [{"email": "test@example.com"}],
"subject": "Sending with SendGrid is Fun",
}
],
"from": {"email": "test@example.com"},
"content": [
{"type": "text/plain", "value": "and easy to do anywhere, even with Python"}
],
}
async with aiosendgrid.AsyncSendGridClient(api_key=SENDGRID_API_KEY) as client:
response = await client.send_mail_v3(body=data)
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
aiosendgrid-0.1.0.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file aiosendgrid-0.1.0.tar.gz
.
File metadata
- Download URL: aiosendgrid-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Darwin/19.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6885729a0ed29e6e7ea2e6ecaad73a31a1699a2418530c75694f8c76c6987d9 |
|
MD5 | 5add6c65f6ee5f01e12645f94ea1bc88 |
|
BLAKE2b-256 | 60b199d78ad343fa953977ff02ce3553d5e94a5ab93d28a35caf941db1853c75 |
File details
Details for the file aiosendgrid-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: aiosendgrid-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Darwin/19.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab8abc62db477e08b21cb83243b56b40316c2c9365c86f2b72bca156f32a7ca4 |
|
MD5 | 054f2d9ad606e6b37cd0c1a042940b80 |
|
BLAKE2b-256 | 27fac21efe03089d3231e4a142341ecd759c1fbab01f401d67a38999328c35cf |