0

I am trying to send email from flask my app using Flask-Mail. My code works fine when I run it from the development server but when I deployed it using uwsgi and nginx, I no longer can send email. Error traceback is provided. How can I solve this issue?

Traceback (most recent call last):
  File "./resources/forget_password.py", line 41, in post
    mail.send(msg)
  File "/home/www/shopolot/env/local/lib/python2.7/site-packages/flask_mail.py", line 491, in send
    with self.connect() as connection:
  File "/home/www/shopolot/env/local/lib/python2.7/site-packages/flask_mail.py", line 144, in __enter__
    self.host = self.configure_host()
  File "/home/www/shopolot/env/local/lib/python2.7/site-packages/flask_mail.py", line 158, in configure_host
    host = smtplib.SMTP(self.mail.server, self.mail.port)
  File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 316, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
error: [Errno 111] Connection refused
salmanwahed
  • 9,450
  • 7
  • 32
  • 55

1 Answers1

3

I had same trouble until add "threads = 2" in my wsgi config file. And, almost forgot, for mailing I use Threads.