wger-project / docker

Production...ish docker-compose image for wger
GNU Affero General Public License v3.0
137 stars 46 forks source link

Email issue #100

Open hubortje opened 1 month ago

hubortje commented 1 month ago

Hey, when trying to send a verification email, the container throws the following error

web | WARNING 2024-09-21 18:54:26,780 confirm WARNING: the URL seems to be malformed - http://localhost/email/email/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImV4YW1wbGVAZXhhbXBsZS5jb20iLCJleHAiOjE3MjY5NDEyNjYuNzc4MDk1LCJraW5kIjoiTUFJTCJ9.29z292u5b79_ffGEpoU0NBB6dvhkMC-nybw1YJRIk7Q

web  | Exception in thread Thread-2 (send_inner_thread):
web  | Traceback (most recent call last):
web  |   File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
web  |     self.run()
web  |   File "/usr/lib/python3.10/threading.py", line 953, in run
web  |     self._target(*self._args, **self._kwargs)
web  |   File "/usr/local/lib/python3.10/dist-packages/django_email_verification/confirm.py", line 97, in send_inner_thread
web  |     msg.send()
web  |   File "/usr/local/lib/python3.10/dist-packages/django/core/mail/message.py", line 299, in send
web  |     return self.get_connection(fail_silently).send_messages([self])
web  |   File "/usr/local/lib/python3.10/dist-packages/django/core/mail/backends/smtp.py", line 127, in send_messages
web  |     new_conn_created = self.open()
web  |   File "/usr/local/lib/python3.10/dist-packages/django/core/mail/backends/smtp.py", line 85, in open
web  |     self.connection = self.connection_class(
web  |   File "/usr/lib/python3.10/smtplib.py", line 255, in __init__
web  |     (code, msg) = self.connect(host, port)
web  |   File "/usr/lib/python3.10/smtplib.py", line 343, in connect
web  |     (code, msg) = self.getreply()
web  |   File "/usr/lib/python3.10/smtplib.py", line 405, in getreply
web  |     raise SMTPServerDisconnected("Connection unexpectedly closed")
web  | smtplib.SMTPServerDisconnected: Connection unexpectedly closed
web  | Exception in thread Thread-3 (send_inner_thread):
web  | Traceback (most recent call last):
web  |   File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
web  |     self.run()
web  |   File "/usr/lib/python3.10/threading.py", line 953, in run
web  |     self._target(*self._args, **self._kwargs)
web  |   File "/usr/local/lib/python3.10/dist-packages/django_email_verification/confirm.py", line 97, in send_inner_thread
web  |     msg.send()
web  |   File "/usr/local/lib/python3.10/dist-packages/django/core/mail/message.py", line 299, in send
web  |     return self.get_connection(fail_silently).send_messages([self])
web  |   File "/usr/local/lib/python3.10/dist-packages/django/core/mail/backends/smtp.py", line 127, in send_messages
web-  |     new_conn_created = self.open()
web  |   File "/usr/local/lib/python3.10/dist-packages/django/core/mail/backends/smtp.py", line 85, in open
web  |     self.connection = self.connection_class(
web  |   File "/usr/lib/python3.10/smtplib.py", line 255, in __init__
web  |     (code, msg) = self.connect(host, port)
web  |   File "/usr/lib/python3.10/smtplib.py", line 343, in connect
web  |     (code, msg) = self.getreply()
web  |   File "/usr/lib/python3.10/smtplib.py", line 405, in getreply
web  |     raise SMTPServerDisconnected("Connection unexpectedly closed")
web  | smtplib.SMTPServerDisconnected: Connection unexpectedly closed

I've changed the JSON web token to display the domain "example@example.com" and fudged with the exp-value. If you need these to debug, tell me please.

From my wger.env-file:

ENABLE_EMAIL=True
EMAIL_HOST=smtp.strato.de
EMAIL_PORT=465
EMAIL_HOST_USER=user@strato.de
EMAIL_HOST_PASSWORD='pa#ss'word*'
EMAIL_USE_TLS=True
EMAIL_USE_SSL=False
FROM_EMAIL='wger Workout Manager'
bbkz commented 1 month ago

Try with

FROM_EMAIL='user@strato.de'

This must be a mail address the mailserver is accepting to send from, with the given user EMAIL_HOST_USER.

But i found the following bug report: #35

CYPH4R commented 1 month ago

I've had the same issue and i fixed it by setting DEBUG=False in the prod.env file. Somewhere else it said that the DEBUG variable sets the Django server into Dev mode and certain things break.

Also you seem to have forgotten to set the SITE_URL variable to the actual domain where you are running your server on. If you don set that the confirmation email has a link that starts with https://localhost and that doesn't point to your wger instance (unless you run it on your local machine)