Sending Mails times out
I am trying to set up the mail settings, so far without luck.
At first I tried using GMails SMTP Relay service (Option 1) found here: https://support.google.com/a/answer/176600?hl=en
I could not get this to work using the "Test Mail Preferences".
I also tried the Option 2 under the above link using the SMTP server directly using an App Password. This also fails.
In both cases I get timeout errors (from the logs):
172.18.0.2 - - [22/Apr/2025:23:10:39 +0000] "POST /-/admin/mail_preferences HTTP/1.1" 504 167 "https://wiki.[REDACTED].com/-/admin/mail_preferences" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0"
2025/04/22 23:10:39 [error] 15#15: *45 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.18.0.2, server: , request: "POST /-/admin/mail_preferences HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock", host: "wiki.[REDACTED].com", referrer: "https://wiki.[REDACTED].com/-/admin/mail_preferences"
172.18.0.2 - - [22/Apr/2025:23:11:39 +0000] "GET /favicon.ico HTTP/1.1" 504 167 "https://wiki.[REDACTED].com/-/admin/mail_preferences" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0"
2025/04/22 23:11:39 [error] 15#15: *45 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.18.0.2, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock", host: "wiki.[REDACTED].com", referrer: "https://wiki.[REDACTED].com/-/admin/mail_preferences"
172.18.0.2 - - [22/Apr/2025:23:11:48 +0000] "GET / HTTP/1.1" 504 167 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0"
2025/04/22 23:11:48 [error] 15#15: *54 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.18.0.2, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock", host: "wiki.[REDACTED].com"
[2025-04-22 23:11:55,655] ERROR in helper: send_async_email(): Exception [Errno 101] Network is unreachable
Tue Apr 22 23:11:55 2025 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /-/admin/mail_preferences (ip 172.18.0.2) !!!
Tue Apr 22 23:11:55 2025 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /-/admin/mail_preferences (172.18.0.2)
OSError: write error
Tue Apr 22 23:11:55 2025 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /favicon.ico (ip 172.18.0.2) !!!
Tue Apr 22 23:11:55 2025 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET /favicon.ico (172.18.0.2)
OSError: write error
Tue Apr 22 23:11:55 2025 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / (ip 172.18.0.2) !!!
Tue Apr 22 23:11:55 2025 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET / (172.18.0.2)
OSError: write error
What is the recommended setup? For full disclosure, I am running the docker container behind a Cloudflare tunnel. For this reason I have not used the possibility in the SMTP relay option to restrict to certain IP addresses. For my office printer this worked fine, but I can't guarantee that the tunnel IP won't change.
Hey @hiwigiwi, hope I canm help you with this. I just tested with success the Option 2, created an app password as described here and configured the following settings:
MAIL_SERVER='smtp.gmail.com'
MAIL_PORT=465
MAIL_USERNAME='[email protected]'
MAIL_PASSWORD='aaaa bbbb cccc dddd'
MAIL_USE_SSL=True
I obviously obfuscated the password (I used it as displayed with the spaces) and the complete Google Workspace email address.
I recommend you try this option again.
Still no luck with this.
My email is my company email of the form "[email protected]". But it is managed through our company google account, i.e. Gmail. The app password I set in the Google Dashboard is for that same company email address, so that should be OK...
I also double checked that the relevant ports are open, and even completely disabling my ufw firewall, but it makes no difference...
Sorry, I didn't think about it properly yesterday. The problem is not the auth, the problem is the network interconnect.
...
.. Exception [Errno 101] Network is unreachable
...
Looks to me like the pod is not able to connect to smtp.gmail.com. There could be multiple reasons, UFW blocking docker has been ruled out, but still hard to say.
Lets rule out that An Otter Wiki is the problem. You could run a test using swaks which is for example build into netshoot, that can be run as one shot pod:
docker run -it --rm nicolaka/netshoot
At the prompt run
swaks -t [email protected] -s smtp.gmail.com:465 -tlsc -a LOGIN
This will ask you for username and password, be aware the password is displayed in clear text:
Username: [email protected]
Password:
On success this will send a testmail to yourself.
This also seems to fail with a "Network unreachable" error:
=== Trying smtp.gmail.com:465...
*** Error connecting to smtp.gmail.com:465:
*** Network unreachable
I actually had to run docker run -it --network cloudflared --rm nicolaka/netshoot as I run all my docker images (including Otter) on my VPS on a cloudflare tunnel (the network name "cloudflared" is the local network that the tunnel and all other images run on). It was my understanding that this tunnel should not be a hinderness for outgoing SMTP mail..... but I am starting to realise that it may be...
I hope you figure it out. Will close this issue, since whatever causes the problem is out of An Otter Wikis scope.