-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error while trying to send e-mail #462
Comments
Hi, not sure what the problem is. Here is a minimal example, can you please run that directly in Python and try out which configuration works for you? import smtplib
from email.message import EmailMessage
from email.utils import make_msgid
msg = EmailMessage()
msg.set_content("Hello World.")
msg["Subject"] = "Test"
msg["From"] = "[email protected]"
msg["To"] = "[email protected]"
msg["Message-ID"] = make_msgid()
host = "smtp.office365.com"
port = 587
user = "[email protected]"
password = "my-app-password"
use_tls = True # try with False as well
if use_tls:
smtp = smtplib.SMTP_SSL(host=host, port=port, timeout=10)
else:
smtp = smtplib.SMTP(host=host, port=port, timeout=10)
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
smtp.login(user, password)
smtp.send_message(msg)
smtp.quit() |
@DavidMStraub first of all, thanks for quick reply. I just created a quick and dirty
With Just in case, I have double checked it now. I have (again) tested Gramps using |
Viewin the source at: https://github.com/gramps-project/gramps-webapi/blob/ad17934c976bd8421d3ef601ac2cfbb9bc4fe605/gramps_webapi/api/util.py#L392-L396 However, when we used those environment variable names (without prefix) we received a bunch of messages like these in
Maybe by fixing those warnings in |
No, that's fine. But indeed it's very puzzling that it works for you using the above script, but not in Gramps Web. You are using the default docker images, right? |
I think the problem is that you are using |
Yes, that was it! Using GRAMPSWEB_EMAIL_USE_TLS: "false" in lowercase did the trick. I started using the docker-compose.yaml from https://github.com/gramps-project/web/blob/main/examples/docker-compose-base/docker-compose.yml and ended customising it a bit with some extra environment variables for the email feature. I thought that Python would do that trivial conversions from string to boolean values. It seems I was wrong. Maybe updating that file with these environment variables, and some comments would avoid others this very same issue in the future. Thanks a lot for you help. |
Thanks! I added a warning to the docs: gramps-project/gramps-web-docs@efc54b1 Not allowing anything but |
We have a docker-compose install running but whenever a users tries to reset his password throght the lost password/reset password feature we can see the following lines in the logs of
grampsweb_celery
container:We are using the following docker-compose environment variables:
As you can see we are sending the emails from an @outlook.com address via smtp.office365.com host using an application password created through the page https://account.live.com/proofs/Manage/additional (for more information about app passwords, see https://go.microsoft.com/fwlink/?LinkId=277093 )
We have the email feature set up this way in other devices/services (because the sending email address has Multifactor Authenticator enabled) and it works perfectly fine. It does not matter if we try with TLS: true or false when using PORT: 587. Both cases yield the same results.
However, when using PORT 465, the errors are slightly different (with this port it fails a line earlier, "/usr/lib/python3.11/smtplib.py", line 1056):
The error when using port 587 is related to [SSL: WRONG_VERSION_NUMBER]. Maybe it is something related to the version of TLS being used (TLS 1.1 is now deprecated).
The text was updated successfully, but these errors were encountered: