SamR1/FitTrackee

Error mail flask worker

maximushugus opened this issue · 6 comments

I have issues trying to send mail with Fittrackee.
As I said in another issue witch is resolved, I installed Fittrackee using this container.
I'm able to configure the EMAIL_URL variable without any error when I launch Fittrackee.

When trying to send mail, nothing happen so from inside the docker container I tried this command : flask worker --processes 2 and I tried again to send mail.
This time, in the output of the previous command, I get this error :

2023/11/01 23:43:42 - dramatiq.worker.WorkerThread - ERROR - Failed to process message account_confirmation_email({'language': 'fr', 'email': 'test@test.fr'}, {'username': 'divers', 'fittrackee_url': 'https://test.fr', 'operating_system': 'Windows', 'browser_name': 'Firefox', 'account_confirmation_url': 'https://test.fr/account-confirmation?token=qFtf6cAZFUFmz5Al2ksJCXXvjL3Bzip1bAUBlWYm'}) with unhandled exception.
Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/dramatiq/worker.py", line 485, in process_message
    res = actor(*message.args, **message.kwargs)
  File "/opt/venv/lib/python3.10/site-packages/dramatiq/actor.py", line 177, in __call__
    return self.fn(*args, **kwargs)
  File "/usr/src/app/fittrackee/emails/tasks.py", line 48, in account_confirmation_email
    email_service.send(
  File "/usr/src/app/fittrackee/emails/email.py", line 165, in send
    with self.smtp(
  File "/usr/local/lib/python3.10/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python3.10/smtplib.py", line 341, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/local/lib/python3.10/smtplib.py", line 312, in _get_socket
    return socket.create_connection((host, port), timeout,
  File "/usr/local/lib/python3.10/socket.py", line 845, in create_connection
    raise err
  File "/usr/local/lib/python3.10/socket.py", line 833, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

I do not understand what is the problem.
Could someone give me help ?

Thanks !

SamR1 commented

Hi,

sorry for the delay.
can you check if the mail server is reacheable from the container?

No problem.
Yes from the container I can access the mail server (I can wget a HTML page on the same server).

SamR1 commented

OK, thanks for your reply. Have you tried using the mail server port?

If you mean specifying the email server port in the EMAIL_URL variable : yes, I use port 587.
I also tried from a shell inside the container to do wget mail.example.fr:587 and I can access the mail server as I obtain a response 220 ...

Hi,

Thanks for your answer.
I have set up a new instance with the same docker image and an SMTP server (EMAIL_URL=smtp://username:password@smtp.example.fr:587?tls=True). Emails are sent without error.

Maybe the SMTP server is blocking the connection?

For information, a CLI is available, especially for single-user instance (it allows to configure FitTrackee without an SMTP server).

I do not know if there was an update on this container, but today, if I run from inside the container the command flask worker --processes 2, I receive mail. I was not the case 2 weeks ago.
Problem solved