I am wondering if this is even the best approach, but the Flask-Mail extension accepts some SMTP
server configs, and calls the send
function of the Mail
class anytime an email is to be sent.
I am using an SMTP
provider, and have written my own send function, that leverages the Message object of the Flask-Mail extension, and now I would like to patch the mail object to use this custom function.
I've tried the following:
from flask_mail import Mail
#override the send email to use
#the elastic email
Mail.send = _custom_send
app = Flask(__name__)
mail = Mail()
mail.init_app(app)
And
app = Flask(__name__)
mail = Mail()
mail.send = types.MethodType(_custom_send, mail)
mail.init_app(app)
However, the existing send
function of the Mail
class is still being called.
Any ideas?