knadh / listmonk

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
https://listmonk.app
GNU Affero General Public License v3.0
13.91k stars 1.25k forks source link

SMTP timeout failure #1842

Open krair opened 2 months ago

krair commented 2 months ago

Version:

Description of the bug and steps to reproduce: I suppose the is related to the other thread(s) on SMTP failure. I am also getting the I/O timeout error as described in https://github.com/knadh/listmonk/issues/1492

I am using Mailjet as my smtp relay.

The initial setup (and test) of SMTP works just fine, the test email works great. However, subsequent emails (like a double opt-in) don't make it to the SMTP server and I get an error in the log:

2024/04/24 20:45:11 manager.go:513: error sending message 'Confirm subscription': dial tcp 104.199.96.85:465: i/o timeout

If I switch the port to 587 for example, the test email will go through fine, and subsequent messages will go through, but not for long. Switching back to port 465 will also work again for some time, but eventually I hit the same error.

krair commented 2 months ago

I should add that I use the exact same SMTP server, with the exact same SMTP settings, on the same server, in an app in a different container, and that works without failing after a period of time.

knadh commented 2 months ago

hm, this seems related to https://github.com/knadh/listmonk/issues/1837 and similar issues in the past. The app's attempt to establish an outgoing TCP connection fails. This has to be in Docker/network/environment/firewall ... At his point, I'm at a loss ;(

krair commented 2 months ago

I don't know if this helps, but if I setup the smtp with the correct settings, the test email goes through.

Next, I click save settings, app reloads, I am still able to successfully send the test email (without leaving the page).

However, if I leave the page (go to dashboard for example) and return to the smtp settings, the test email fails with the i/o timeout error.

If I then change a setting like TLS from STARTTLS to TLS/SSL, and back to STARTTLS (never clicking save or anything else) the test email goes through just fine. There appears to be a bug in here, but I don't know go/js enough to start digging.

knadh commented 2 months ago

When you change any setting and save, listmonk does a full restart. So something's getting flushed/cleared which is why it works. Then whatever's blocking the connection kicks in and connections fail. I'm at a loss here as to what could be blocking the connections and how.

krair commented 2 months ago

I think you misread what I said. When I change a setting BUT DON'T SAVE, it also works.

knadh commented 2 months ago

That's just a coincidence. Changing the setting on the UI without hitting save has no effect on the backend. That's just a browser/UI thing.

krair commented 2 months ago

I tried to create a screen recording to show, and its true I can't get it to reliably reproduce the timeout error every time.

I will try running listmonk as a standalone binary and see if the error still exists.

Thank you anyways for the great app!

MaximilianKohler commented 2 months ago

If you're using docker it may be a firewall issue. See https://github.com/knadh/listmonk/issues/1837#issuecomment-2070181984.

Docker may be opening some ports after you make a change, and then your firewall blocks them again.

krair commented 2 months ago

@MaximilianKohler Thanks for the feedback, but firewalld with podman does not have the same outgoing restrictions. As stated above, the issue is intermittent. I will also try increasing the number of retries, and the timeout/wait times to see if it will clear up the issue.