from flask import Flask from flask_mail import Mail app = Flask(__name__) mail = Mail(app) mail.init_app(app)
from flask import Flask from flask_mail import Mail app = Flask(__name__) mail = Mail() def create_app(app): mail.init_app(app) create_app(app)In this example, we create a Mail object without passing in the Flask app. Instead, we define a function create_app() that takes in the Flask app and initializes the Mail object using the init_app() method. Overall, the Flask-Mail package is a convenient and flexible way to send email messages from Flask applications. It is widely used and well-maintained, making it a reliable choice for developers working with Flask.