Skip to main content
Help us improve Python packaging – donate today!

SendGrid mail send API wrapper

Project Description

https://travis-ci.org/Kurlov/aiohttp-sendgrid.svg?branch=master

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.

Release history Release notifications

This version
History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
aiohttp_sendgrid-0.0.4-py3-none-any.whl (6.1 kB) Copy SHA256 hash SHA256 Wheel py3 Jan 10, 2018
aiohttp_sendgrid-0.0.4.tar.gz (5.0 kB) Copy SHA256 hash SHA256 Source None Jan 10, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page