Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

Flask-Mail not working when deployed to Heroku

$
0
0

I am attempting to deploy my python-flask backend to heroku while using flask-mail. Everything works fine on local host. But my server keeps crashing on heroku.

from flask import Flask, jsonify, request
from flask_mail import Mail, Message
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)


app.config['TESTING'] = False
app.config['MAIL_SERVER'] = 'mail.gmx.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USERNAME'] = 'some-email'
app.config['MAIL_PASSWORD'] = 'some-password'
app.config['MAIL_DEFAULT_SENDER'] = ('Some email', 'some-email')
app.config['MAIL_MAX_EMAILS'] = None
app.config['MAIL_ASCII_ATTACHMENTS'] = False

mail = Mail(app)



@app.route('/mail')
def send():
    msg = Message('Welcome!', recipients=['some-email'])
    msg.html = '<b>Welcome to Wx Safe Flight! Enjoy, and may good weather be with you!</b>'
    mail.send(msg)

    return 'Message has been sent!'


if __name__ == '__main__':
    app.run(threaded=True, port=5000)


Viewing all articles
Browse latest Browse all 29758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>