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

I have the correct credentials but my emails wont go through using flask_mail

$
0
0

I am trying to use flask_mail to send emails with Gmail but for some reason, my emails won't go through. I successfully manage to login to my Gmail account just to ensure that my password is correct.

The function looks like the following:

def send_reset_email(user):
    token = user.get_reset_token()

    msg = Message('Password reset request', sender='myemail@gmail.com', recipients=['anotheremail@example.com'])
    msg.body = f'''To reset your password visit the following link:
{url_for('reset_token', token=token, _external=True)}

If you did not make this request simply ignore this email and no changes will be made
    '''
    mail.send(msg)

Inside my init.py I have the following configurations for flask mail:

from flask_mail import Mail

######## EMAIL CONFIURATION ##########
app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_POST'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'myemail@gmail.com'
app.config['MAIL_PASSWORD'] = 'mygmailpassword'

mail = Mail(app)

When I press the button to send the email I see the following error:

smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials v13sm322058edy.8 - gsmtp')

Note: I already went to my Gmail settings and disabled less secure apps

How do I use flask-mail to send emails?

EDITED: The answer of this link does not answer my question because I still see the same error. I changed my mail server to smtp.gmail.com but nothing.


Viewing all articles
Browse latest Browse all 29745

Trending Articles



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