Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask
- from flask_mail import Mail, Message
- app =Flask(__name__)
- mail=Mail(app) # <-- This
- app.config['MAIL_SERVER']='smtp.gmail.com'
- app.config['MAIL_PORT'] = 465
- app.config['MAIL_USERNAME'] = 'yourId@gmail.com'
- app.config['MAIL_PASSWORD'] = '*****'
- app.config['MAIL_USE_TLS'] = False
- app.config['MAIL_USE_SSL'] = True
- mail = Mail(app) # <-- This
- @app.route("/")
- def index():
- msg = Message('Hello', sender = 'yourId@gmail.com', recipients = ['id1@gmail.com'])
- msg.body = "Hello Flask message sent from Flask-Mail"
- mail.send(msg)
- return "Sent"
- if __name__ == '__main__':
- app.run(debug = True)
Add Comment
Please, Sign In to add comment