Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. req.txt
  2. Flask==0.10.1
  3. Flask-Mail==0.9.1
  4.  
  5. app.py
  6. from flask import Flask, request
  7. from flask_mail import Mail
  8.  
  9. app = Flask(__name__)
  10. app.config.update(
  11. MAIL_SERVER='smtp.yandex.ru',
  12. MAIL_PORT=465,
  13. MAIL_USE_SSL=True,
  14. MAIL_USERNAME = 'OWNER_MAILLIKE_noreply',
  15. MAIL_PASSWORD = 'YOUR_PWD'
  16. )
  17.  
  18. mail = Mail(app)
  19.  
  20. @app.route("/")
  21. def hello():
  22. return "Hello World!"
  23.  
  24. @app.route('/send-mail/', methods=['POST'])
  25. def send_mail():
  26.  
  27. r = request.get_json()
  28. name = r.get('name','Empty')
  29. user_mail = r.get('email','Empty')
  30. message = r.get('message','Empty')
  31. msg = mail.send_message(
  32. 'Сообщение с skyeermap.com',
  33. sender='no-reply@skyeermap.com',
  34. recipients=['info@skyeermap.com'],
  35. body="User: %s User Email: %s User message: %s"%(name, user_mail, message)
  36. )
  37. return 'Mail sent'
  38.  
  39. if __name__ == "__main__":
  40. app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement