Skip to content

Flask plugin to simplify sending emails through SendGrid.

License

Notifications You must be signed in to change notification settings

frankV/flask-sendgrid

Repository files navigation

flask-sendgrid

PyPI version Travis Build Coverage Status

Flask plugin for sending emails with SendGrid.

Provides full support for all Twilio SendGrid Web API v3 endpoints, including v3 /mail/send.

Installation

pip install flask-sendgrid

Usage

from flask_sendgrid import SendGrid
app = Flask(__name__)
app.config['SENDGRID_API_KEY'] = 'your api key'
app.config['SENDGRID_DEFAULT_FROM'] = '[email protected]'
mail = SendGrid(app)

# send multiple recipients; backwards compatible with Flask-Mandrill
mail.send_email(
    from_email='[email protected]',
    to_email=[{'email': '[email protected]'}, {'email': '[email protected]'}],
    subject='Subject',
    text='Body',
)

# send single recipient; single email as string
mail.send_email(
    from_email='[email protected]',
    to_email='[email protected]',
    subject='Subject',
    text='Body',
)

# send single recipient; single email as sendgrid.mail.helpers.Email object
mail.send_email(
    from_email='[email protected]',
    to_email=Email('[email protected]'),
    subject='Subject',
    text='Body',
)

# send multiple recipients; list of emails as sendgrid.mail.helpers.Email object
mail.send_email(
    from_email='[email protected]',
    to_email=[Email('[email protected]'), Email('[email protected]')],
    subject='Subject',
    text='Body',
)

For additional information about mail parameters: SendGrid Web API Mail

About

Flask plugin to simplify sending emails through SendGrid.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages