Flask-Mail not working when deployed to Azure

I deployed my app to Azure, the settings I did not touch.

I get an Http500 error, however, when used via localhost, all works well. What could be the reason for this?

app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = '587' 
app.config['MAIL_USERNAME'] = <username>
app.config['MAIL_PASSWORD'] = <password>
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False

@app.route('/send_message', methods=['GET', 'POST'])
  def send_message():
    if request.method == 'POST':
    email = request.form['email']
    name = request.form['name']
    subject = request.form['subject']
    phone = request.form['phone']
    msg = request.form['message']
    compose_mail =  """
    Name = {},
    Email = {}
    Subject = {},
    Phone = {},
    Message = {}
    """.format(name, email, subject, phone, msg)
    message = Message(subject, sender=email, recipients=['<mail>'])
    message.body  = compose_mail
    return render_template("result.html")

if __name__ == '__main__':

Read more here: https://stackoverflow.com/questions/67012539/flask-mail-not-working-when-deployed-to-azure

Content Attribution

This content was originally published by samantha at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: