Disable logging in Flask-Mail when sending message
Figured this one out:
Flask-Mail uses Python's smtplib to send mail. smtplib does not use the logging module, but it prints information for debugging to stderr.
smtplib includes following method:
def set_debuglevel(self, debuglevel): """Set the debug output level. A non-false value results in debug messages for connection and for all messages sent to and received from the server. """ self.debuglevel = debuglevel
If we use Flask-Mail, we can set this variable when we initialize our app like this:
app = Flask(__name__)mail = Mail(app)app.extensions['mail'].debug = 0
Any output is now suppressed.