SendGrid mail send API wrapper
Project description
SendGrid mail API wrapper
Installation
pip install aiohttp_sendgrid
Usage
Create an instance of API client:
import asyncio
from aiohttp_sendgrid import Sendgrid
api_key = '<your_sendgrid_api_key>'
mailer = Sendgrid(api_key=api_key)
Important to note that if api_key is not provided then it will try to read SENDGRID_API_KEY environment variable
Send email to single recipient
to = 'to@example.com'
sender = 'from@example.com'
subject = 'greetings'
content = '<h1>Hello</h1>'
send_mail = mailer.send(to, sender, subject, content)
loop = asyncio.get_event_loop()
loop.run_until_complete(send_mail)
Both to and sender might be also a dictionary with email key, if you want to specify name for sender or recipient then add name key to the dictionary. Thus, to = {'email': 'to@example.com', 'name': 'Recipient'} is also a correct value.
Send single email to multiple recipients
to = ['to@example.com', 'another@example']
sender = 'from@example.com'
subject = 'greetings'
content = '<h1>Hello</h1>'
send_mail = mailer.send(to, sender, subject, content)
loop = asyncio.get_event_loop()
loop.run_until_complete(send_mail)
to might be tuple or list of strings or dictionaries.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohttp_sendgrid-0.0.4.tar.gz.
File metadata
- Download URL: aiohttp_sendgrid-0.0.4.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed966f5ea95c2dcb324577befb58ef62e6ff3b70b4781e43a880aa1a02027675
|
|
| MD5 |
9661d10aeec52781910dce6db4a6db65
|
|
| BLAKE2b-256 |
741f2f9c6a3b254440d904af87fa0e3ce9fb73b6dff84fce3ef050a79b8b90b9
|
File details
Details for the file aiohttp_sendgrid-0.0.4-py3-none-any.whl.
File metadata
- Download URL: aiohttp_sendgrid-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c7a735b3e92426c3a3afd49340317c4651d22799759ced1fbb9323de3f9799c
|
|
| MD5 |
bcfa7bcf8cc9534900a50f96f8a6ddb5
|
|
| BLAKE2b-256 |
d968621c2a9bee8c45240bf435e54bb04a3a75ddafb5e1fff9614df4b4c352bb
|