Saved Bookmarks
| 1. |
How to add the mailing feature in the Flask Application? |
|
Answer» To send emails, RUN the following command to install the FLASK-MAIL flask EXTENSION: pip install Flask-MailNext, we'll need to configure the Flask Config API to set up MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD, and so on. Then we must import the Message Class, instantiate it, and create a message object before using the mail.send() function to send the email. The following is an example: from flask_mail import Mail, Message from flask import Flask app = Flask(__name__) mail = Mail(app) @app.route("/mail") def email(): MSG = Message( "Hello Message", sender="admin@test.com", recipients=["to@test.com"]) mail.send(msg) |
|