SendGrid using a client based on httpx.
Project description
Python | |
Package | |
Meta |
Async-Sendgrid
Sendgrid simple asynchronous client based on the httpx libarary.
Installation
It is possible to install sendgrid-async with pip:
pip install sendgrid-async
Usage
This is a small script showing how to send an email with async-sendgrid:
First, you need to import the SendgridAPI
from the async_sendgrid
package. Then, you need to create a SendgridAPI
object with your API key.
from async_sendgrid import SendgridAPI
import os
API_KEY = os.environ.get['API_KEY']
sendgrid = SendgridAPI(API_KEY)
Thereafter, you can create an email with the original sendgrid
package such:
from sendgrid.helpers.mail import Content, Email, Mail, To
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=from_email,
to_email=to_email,
subject=subject,
content=content
)
Finally you can send the email with the send
method of the SendgridAPI
instance:
async with sendgrid as client:
response = await client.send(data)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sendgrid_async-1.0.3.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for sendgrid_async-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6bca7691e358eca182753e194e2a8d1628ab4b54a696db056efa7416caadf05 |
|
MD5 | 2ed957d623ae4dd2c9f8a7017db73017 |
|
BLAKE2b-256 | 5dce88317c2dd691d2bf6806dd20a149096412e748b3ac0a5fbf90c147f75d2b |