Flask Red Mail: Email Sending for Flask
Flask extension for Red Mail
What is it?
Flask Red Mail is a Flask extension for Red Mail. Red Mail is a powerful email sender library capable of including attachments from various formats, embedding images, parametrization with Jinja etc. This library harness the power of Red Mail in order to make it trivial to:
- Send verification emails to users
- Create email based forgot password functionality
- Create Flask based email news letters
- Handle other needs for sending emails from a web application
Links:
- Flask-Redmail's source code
- Flask-Redmail's documentation
- Flask-Redmail's releases (PyPI)
- Red Mail's source code
- Red Mail's documentation
- Red Mail's releases (PyPI)
Installation
Install the extension from PyPI:
pip install flask-redmail
Example
Create a simple Flask application:
import flask
from flask_redmail import RedMail
app = flask.Flask(__name__)
email = RedMail(app)
# Configure
app.config["EMAIL_HOST"] = "localhost"
app.config["EMAIL_PORT"] = 0
# Optional
app.config["EMAIL_USER"] = "[email protected]"
app.config["EMAIL_PASSWORD"] = "<PASSWORD>"
app.config["EMAIL_SENDER"] = "[email protected]"
Use the extension:
@app.route("/send")
def send_email():
email.send(
subject="An example",
receivers=["[email protected]"],
html="<h1>An example email.</h1>"
)
Author
- Mikael Koli - Miksus - [email protected]