Closed tomkralidis closed 2 years ago
CI errors seem unrelated.
Thanks for the feedback @justb4. Updates rebased/pushed for review.
@justb4 actually, testing this against an SMTP server that does not support AUTH still results in error. Options:
Note: I've updated the PR now to implement option 2.
login
: in the current situation the exception is logged but ignored further. So I guess that is taken care. But I think a real fix is to optionally call login
regardless of tls
on the condition that a username
/password
is configured. Note that also the config check on lines 81-86 needs to be adapted.
To make things worse: I just saw that there is also a email function in util.py:L177
(where also tls
and login
is combined). That function is e.g. used for lost password.
The ultimate solution I see:
send_email()
function, e.g. in util.py
Later: use a higher-level lib for sending email. e.g. with FastAPI I use FastAPI-mail
which you just provide a config and it takes care of all those details. SMTPLib
is too low-level. On the other hand, we have one dependency less...
@justb4 I've added testing for username and password settings. I also had to add a str2None
function in docker/config_site.py
to be able to cast environment variables that are 'None'
as None
.
At this point I think there is enough in this PR to cover the intent/fix. Agree that we should plan for streamlining email handling as part of a future PR.
Strictly speaking, if username
+ password
is set and login
fails we should return (now only exception logging). Ok, but the sendmail will fail then anyway and this is the current behaviour.
Note that the util.py
send_mail()
function is also used to mail a daily summary...
But let's proceed/merge and open an issue to streamline all email functionality.
I'll open the issue.
This PR fixes a bug in GHC's Docker setup of
GHC_SMTP_*
environment variables that were not getting cast as booleans, and resulting in'False'
values evaluating toTrue
in GHC notifications. In addition, TLS handling has been streamlined for better flow and error handling.