Forums

Flask-Mail using gmail issue. [Errno 111] Connection refused

Hi, I am currently attempting to send a gmail message through my pythonanywhere website. I am using flask_mail and I keep getting an error connecting.

I configured it like so:

app.config.update(
    DEBUG=True,
    #EMAIL SETTINGS
    MAIL_SERVER='smtp.gmail.com',
    MAIL_PORT=465,
    MAIL_USE_SSL=True,
    MAIL_USERNAME = 'blah@gmail.com',
        MAIL_PASSWORD = 'password'
)

The error in the error log shows up like:

2017-12-05 23:23:37,363: Error running WSGI application 2017-12-05 23:23:37,371: ConnectionRefusedError: [Errno 111] Connection refused

...

2017-12-05 23:23:37,390: File "/usr/lib/python3.5/socket.py", line 702, in create_connection 2017-12-05 23:23:37,391: sock.connect(sa)

I have tested it locally and it works. I believe there is a problem with the host. Any suggestions?

have a look at the "google security blocking" section on this page: https://help.pythonanywhere.com/pages/SMTPForFreeUsers -- could that be it?

Have you had any solutions, same probelm with my setup

Did you go to the help link and follow the instructions?