SamR1/FitTrackee

Cannot send mail (unraid)

maximushugus opened this issue · 10 comments

First I would like to thank the developpers for this awesome project.

I set up FitTrackee on docker on Unraid.
To do this on Unraid :

  1. I set up a Postgresql container, and created a database for FitTrackee
  2. I set up this container on docker with all the variables needed : https://hub.docker.com/r/nowsci/fittrackee
  3. Open a shell inside the container and run "ftcli db drop" and "ftcli db upgrade"
  4. Create a user with the web UI
  5. Open a shell inside the container and run "ftcli users update REPLACEWITHUSERNAME --set-admin true"

Everything seem to work.

But I'm not able to set up mail :
My mail server runs with startls so I set the variable EMAIL_URL this way : "smtp://username:password@smtp.example.com:587/?tls=True"
For my mail server, the user is mail@server.com, and my mail account contains "?, @ and &" caracter
So if I this the variable for EMAIL_URL is "smtp://mail@server.com:passwith@and&and?@smtp.server.com:587?tls=True" I get an error and the container cannot run because I think the first @ is not escaped.

So I tried "smtp://mail%40server.com:passwith%3Fand%40and%26@smtp.server.com:587?tls=True".
With this variable, the container can run without any error.
But if I try to send a mail (for exemple to confirm a user) : nothing happens, the mail is not send and this is no error on logs...

If someone have an idea ?

Thanks

Did you configurate Redis?
See

# Redis (required for API rate limits and email sending)

Yes, I forgot to specify this in my first post, I already had a redis docker, and configured my Fittrackee container with the variable for redis.

Hi,

On startup, FitTrackee loads the email config from EMAIL_URL. If it cannot parse the environment variable, it raises an error.
If there is no error at startup, it only means that EMAIL_URL can be parsed (credentials may be invalid).

If no email is sent and there are no errors in the logs, it seems that the dramatiq workers have not been started.
Can you check if the workers are running?
(just for information, I'm not the maintainer of the docker image)

Encoded passwords are not decoded by FitTrackee, I'll fix that. Thanks for the bug report.

By running a shell inside the container, I executed this command :
"flask worker --processes=2 >> dramatiq.log 2>&1"
But nothing happens.
Inside the "dramatiq.log" I have this error :

2023/10/02 15:09:01 - dramatiq.worker.WorkerThread - ERROR - Failed to process message account_confirmation_email({'language': 'fr', 'email': 'mail@server.fr'}, {'username': 'divers', 'fittrackee_url': 'https://fittrackee.server.fr', 'operating_system': 'Windows', 'browser_name': 'Firefox', 'account_confirmation_url': 'https://fittrackee.server.fr/account-confirmation?token=q8PCPWxZSj4iGnudb504fV28WXkB_9GHg9hP4mua'}) 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 173, in send
smtp.login(self.username, self.password) # type: ignore
File "/usr/local/lib/python3.10/smtplib.py", line 750, in login
raise last_exception
File "/usr/local/lib/python3.10/smtplib.py", line 739, in login
(code, resp) = self.auth(
File "/usr/local/lib/python3.10/smtplib.py", line 662, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication failed:')

thanks for the feedback.

encoded password is not decoded, the MR #433 will fix this bug (fix not yet released).

Thanks
With this fix, are we supposed to put the EMAIL_URL with quotation marks or use encoded caracters as here ?

With encoded characters.
For instance with password passwith@and&and?, the EMAIL_URL will be: smtp://user_name@mail.example.com:passwith%40and%26and%3F@mail.example.com:587?tls=True

Ok
The "@" character in the username doesn't need to be encoded ?

Yes, no need to encode the @ in username.

fix on encoded password released in v0.7.24