Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- req.txt
- Flask==0.10.1
- Flask-Mail==0.9.1
- app.py
- from flask import Flask, request
- from flask_mail import Mail
- app = Flask(__name__)
- app.config.update(
- MAIL_SERVER='smtp.yandex.ru',
- MAIL_PORT=465,
- MAIL_USE_SSL=True,
- MAIL_USERNAME = 'OWNER_MAILLIKE_noreply',
- MAIL_PASSWORD = 'YOUR_PWD'
- )
- mail = Mail(app)
- @app.route("/")
- def hello():
- return "Hello World!"
- @app.route('/send-mail/', methods=['POST'])
- def send_mail():
- r = request.get_json()
- name = r.get('name','Empty')
- user_mail = r.get('email','Empty')
- message = r.get('message','Empty')
- msg = mail.send_message(
- 'Сообщение с skyeermap.com',
- sender='no-reply@skyeermap.com',
- recipients=['info@skyeermap.com'],
- body="User: %s User Email: %s User message: %s"%(name, user_mail, message)
- )
- return 'Mail sent'
- if __name__ == "__main__":
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement