Guest User

Untitled

a guest
Dec 10th, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. from flask import Flask, render_template, redirect, url_for
  2. from flask_mail import Mail, Message
  3.  
  4. app = Flask(__name__)
  5. app.config.update(
  6. MAIL_SERVER='smtp@gmail.com',
  7. MAIL_PORT=587,
  8. MAIL_USE_SSL=True,
  9. MAIL_USERNAME = 'ri******a@gmail.com',
  10. MAIL_PASSWORD = 'Ma*****fe'
  11. )
  12.  
  13. mail = Mail(app)
  14.  
  15. @app.route('/send-mail/')
  16. def send_mail():
  17. msg = mail.send_message(
  18. 'Send Mail tutorial!',
  19. sender='ri******a@gmail.com',
  20. recipients=['ri*********07@msn.com'],
  21. body="Congratulations you've succeeded!"
  22. )
  23. return 'Mail sent'
  24.  
  25. MAIL_SERVER = 'smtp.gmail.com'
  26. MAIL_PORT = 465
  27. MAIL_USE_SSL = True
  28. MAIL_USERNAME = 'username@gmail.com'
  29. MAIL_PASSWORD = 'app password generated in step 3'
Add Comment
Please, Sign In to add comment