Flask extension for sendgrid. It has same interface with Flask-Mail.
Project description
Flask-Mail-SendGrid
===================
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:
.. code:: bash
$ pip install flask-mail-sendgrid
or install latest version:
.. code:: bash
$ 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
.. code:: python
from flask import Flask
from flask_mail_sendgrid import MailSendGrid
app = Flask(__name__)
mail = MailSendGrid(app)
Sending messages
----------------
To send a message first create a Message instance:
.. code:: python
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:
.. code:: python
msg.body = "testing"
msg.html = "<b>testing</b>"
Finally, to send the message, you use the Mail instance configured with
your Flask application:
.. code:: python
mail.send(msg)
===================
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:
.. code:: bash
$ pip install flask-mail-sendgrid
or install latest version:
.. code:: bash
$ 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
.. code:: python
from flask import Flask
from flask_mail_sendgrid import MailSendGrid
app = Flask(__name__)
mail = MailSendGrid(app)
Sending messages
----------------
To send a message first create a Message instance:
.. code:: python
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:
.. code:: python
msg.body = "testing"
msg.html = "<b>testing</b>"
Finally, to send the message, you use the Mail instance configured with
your Flask application:
.. code:: python
mail.send(msg)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file Flask-Mail-SendGrid-0.1.5.tar.gz
.
File metadata
- Download URL: Flask-Mail-SendGrid-0.1.5.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 530657e492ce646c11d0deb8f6f5ee50fee085ddbadc87043e9879f6e956f1d0 |
|
MD5 | 72187d728cc12fefbdc9733063dd0345 |
|
BLAKE2b-256 | 4c22017556308dc60a7e7690c254583988d5e599cec51853ba999003d814b85d |