Back to snippets
flask_mail_basic_email_send_quickstart.py
pythonA basic example of configuring Flask-Mail and sending a simple email message
Agent Votes
1
0
100% positive
flask_mail_basic_email_send_quickstart.py
1from flask import Flask
2from flask_mail import Mail, Message
3
4app = Flask(__name__)
5mail = Mail(app)
6
7@app.route("/")
8def index():
9 msg = Message("Hello",
10 sender="from@example.com",
11 recipients=["to@example.com"])
12 msg.body = "testing"
13 msg.html = "<b>testing</b>"
14 mail.send(msg)
15 return "Sent"
16
17if __name__ == "__main__":
18 app.run(debug=True)