Skip to content Skip to sidebar Skip to footer

How To Send Emails With Python And Flask

I am working on my website right now and am trying to send a confirmation email when a user creates an account. How can I do this in Python? Can I even do it in Python on my Flask

Solution 1:

You can use flask_mail for this purpose

To make it work set parameters this way:

app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'youremail@gmail.com' # your email
app.config['MAIL_PASSWORD'] = 'your-password' # your password

Also go to your google account security settings and enable 'Less secure app access’, but google doesn’t really like it and still sometimes you can get errors. In this case just try to play with thaws settings, turn things off and on again, at some point it should definitely work (I’m so convinced, cause this totally works for me)

You also can use the app-specific password in google settings.

Post a Comment for "How To Send Emails With Python And Flask"