def init_app(self, app):
"""Initializes your mail settings from the application settings.
You can use this if you want to set up your Mail instance
at configuration time.
:param app: Flask application instance
"""
state = _Mail(
app.config.get('MAIL_SERVER', '127.0.0.1'),
app.config.get('MAIL_USERNAME'),
app.config.get('MAIL_PASSWORD'),
app.config.get('MAIL_PORT', 25),
app.config.get('MAIL_USE_TLS', False),
app.config.get('MAIL_USE_SSL', False),
app.config.get('MAIL_DEFAULT_SENDER'),
int(app.config.get('MAIL_DEBUG', app.debug)),
app.config.get('MAIL_MAX_EMAILS'),
app.config.get('MAIL_SUPPRESS_SEND', app.testing))
# register extension with app
app.extensions = getattr(app, 'extensions', {})
app.extensions['mail'] = state
return state
评论列表
文章目录