Skip to main content

Flask extension for sendgrid. It has same interface with Flask-Mail.

Project description

Flask extension for sendgrid. It has same interface with Flask-Mail.

Flask-Mail-SendGrid is friendly with another extention such as Flask-Security.

Installing Flask-Mail-SendGrid

Install with pypi:

$ pip install flask-mail-sendgrid

or install latest version:

$ git clone https://github.com/hamano/flask-mail-sendgrid.git
$ cd flask-mail-sendgrid
$ python setup.py install

Configuring Flask-Mail-SendGrid

  • MAIL_SENDGRID_API_KEY: API Key for SendGrid

  • MAIL_DEFAULT_SENDER: default sender

from flask import Flask
from flask_mail_sendgrid import MailSendGrid

app = Flask(__name__)
app.config['MAIL_SENDGRID_API_KEY'] = 'XXXXXXXX'
mail = MailSendGrid(app)

Sending messages

To send a message first create a Message instance:

from flask_mail import Message

@app.route("/")
def index():
    msg = Message("Hello",
                  sender="from@example.com",
                  recipients=["to@example.com"])

The message can contain a body and/or HTML:

msg.body = "testing"
msg.html = "<b>testing</b>"

Or, if you are using Templates in Sendgrid, you may specify a Template ID and Data:

msg.template_id = 'my-template-id'
msg.dynamic_template_data = {'first_name': 'John', 'last_name': 'Doe'}

Finally, to send the message, you use the Mail instance configured with your Flask application:

mail.send(msg)

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

Flask-Mail-SendGrid-0.2.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file Flask-Mail-SendGrid-0.2.tar.gz.

File metadata

  • Download URL: Flask-Mail-SendGrid-0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for Flask-Mail-SendGrid-0.2.tar.gz
Algorithm Hash digest
SHA256 ec17105fe0effe6e293aa64e964cbac593a03a5c7e5aac2716bfe0bf1b9fe4fc
MD5 cf71299a298e0c863cf18fca8f18bb3d
BLAKE2b-256 f799be5e482c8ee5ed9ae51a1c71a083d12584760553097111d321f090d45bcb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page