Connection refused when sending mail with Flask-Mail
You must set up flask config:
app = Flask(__name__)app.config.from_object(__name__)mail = Mail(app)
Use
465
port.
I also have the same issue and I was also using Flask-Mail. It was actually part of Flask-User package. I have also enabled TLS port, since my mail server was using TLS and I disable SSL. I also change the port 465 to 587. The code of my application is follows:
MAIL_PORT = int(os.getenv('MAIL_PORT', '587')) MAIL_USE_SSL = int(os.getenv('MAIL_USE_SSL', False)) MAIL_USE_TLS = int(os.getenv('MAIL_USE_TLS', True))
This change solved my problem.