Guest User

Untitled

a guest
Dec 29th, 2017
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. from flask import Flask
  2. from flask_mail import Mail, Message
  3.  
  4. app =Flask(__name__)
  5. mail=Mail(app) # <-- This
  6.  
  7. app.config['MAIL_SERVER']='smtp.gmail.com'
  8. app.config['MAIL_PORT'] = 465
  9. app.config['MAIL_USERNAME'] = 'yourId@gmail.com'
  10. app.config['MAIL_PASSWORD'] = '*****'
  11. app.config['MAIL_USE_TLS'] = False
  12. app.config['MAIL_USE_SSL'] = True
  13. mail = Mail(app) # <-- This
  14.  
  15. @app.route("/")
  16. def index():
  17. msg = Message('Hello', sender = 'yourId@gmail.com', recipients = ['id1@gmail.com'])
  18. msg.body = "Hello Flask message sent from Flask-Mail"
  19. mail.send(msg)
  20. return "Sent"
  21.  
  22. if __name__ == '__main__':
  23. app.run(debug = True)
Add Comment
Please, Sign In to add comment