Hello, I have the same issue, error 500 when sending mail, with a similar setup: local installation with an internal SMTP relay, on port 25, without authentication and without TLS. The SMTP configuration is fine, I can see a TCP connection and an initial « ehlo kpi » on the SMTP server with tcpdump, then nothing and the error 500 on KoboTB. No error shown in the logs either, except for the 500 itself.
I managed to put KoboTB on debug mode, in order to get better messaging and I got:
- smtplib.SMTPNotSupportedError: STARTTLS extension not supported by server.
And that traceback:
Traceback (most recent call last):
File "/opt/venv/lib/python3.10/site-packages/django/contrib/staticfiles/handlers.py", line 76, in __call__
return self.application(environ, start_response)
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
response = self.get_response(request)
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 130, in get_response
response = self._middleware_chain(request)
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 49, in inner
response = response_for_exception(request, exc)
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 149, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/opt/venv/lib/python3.10/site-packages/django_extensions/management/technical_response.py", line 40, in null_technical_500_response
raise exc_value.with_traceback(tb)
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/views.py", line 149, in dispatch
return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/views.py", line 77, in dispatch
response = super(RedirectAuthenticatedUserMixin, self).dispatch(
File "/opt/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/views.py", line 105, in post
response = self.form_valid(form)
File "/srv/src/kpi/kobo/apps/accounts/mfa/views.py", line 36, in form_valid
return super().form_valid(form)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/views.py", line 162, in form_valid
return form.login(self.request, redirect_url=success_url)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/forms.py", line 196, in login
ret = perform_login(
File "/opt/venv/lib/python3.10/site-packages/allauth/account/utils.py", line 168, in perform_login
response = adapter.pre_login(request, user, **hook_kwargs)
File "/srv/src/kpi/kobo/apps/accounts/adapter.py", line 19, in pre_login
if parent_response := super().pre_login(request, user, **kwargs):
File "/opt/venv/lib/python3.10/site-packages/allauth/account/adapter.py", line 412, in pre_login
send_email_confirmation(request, user, signup=signup, email=email)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/utils.py", line 319, in send_email_confirmation
email_address.send_confirmation(request, signup=signup)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/models.py", line 59, in send_confirmation
confirmation.send(request, signup=signup)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/models.py", line 166, in send
get_adapter(request).send_confirmation_mail(request, self, signup)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/adapter.py", line 549, in send_confirmation_mail
self.send_mail(email_template, emailconfirmation.email_address.email, ctx)
File "/opt/venv/lib/python3.10/site-packages/allauth/account/adapter.py", line 140, in send_mail
msg.send()
File "/opt/venv/lib/python3.10/site-packages/django/core/mail/message.py", line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File "/opt/venv/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
new_conn_created = self.open()
File "/opt/venv/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 67, in open
self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
File "/usr/local/lib/python3.10/smtplib.py", line 771, in starttls
raise SMTPNotSupportedError(
So, even if my configuration is with « EMAIL_USE_TLS=False », the smtplib.py validates if the SMTP server replies with « starttls ». Somehow use_tls get sets somewhere.
To fix this, I stopped KoboTB, completely removed the EMAIL_USE_TLS line from the kobo-env/envfiles/smtp.txt file and restarted KoboTB. And it worked.
Using KoboTB 2.023.04d with kobo-install 8.0.2.