[Solved] SMTP i/o timeout

Hi,

I try to use a custom Mail Server to send emails to user. to verify login. I tried different settings but always get this error:

Screenshot from 2024-10-04 10-32-53

Here are my configs:

And here is my log (I am using mattermost in a container).

{"timestamp":"2024-10-04 08:21:06.130 Z","level":"warn","msg":"Error decoding the config","caller":"api4/system.go:207","path":"/api/v4/email/test","request_id":"cii43nktxiffteigjih3eg8kwe","ip_addr":"172.18.0.3","user_id":"1rd9yxud3tbumd5b6kngjgpduo","method":"POST","error":"EOF"}
{"timestamp":"2024-10-04 08:21:16.133 Z","level":"error","msg":"Connection unsuccessful: unable to connect to the SMTP server: dial tcp 162.55.254.207:587: i/o timeout","caller":"web/context.go:117","path":"/api/v4/email/test","request_id":"cii43nktxiffteigjih3eg8kwe","ip_addr":"172.18.0.3","user_id":"1rd9yxud3tbumd5b6kngjgpduo","method":"POST","err_where":"testEmail","http_code":500,"error":"testEmail: Connection unsuccessful: unable to connect to the SMTP server: dial tcp 162.55.254.207:587: i/o timeout"}

I’ve double-checked the configuration of my web server, and everything seems to be set up correctly. However, I’m still encountering the issues. I would really appreciate any guidance or help you can provide.

One more thing, I am using caddy (as a reverse Proxy) with the following settings:

mattermost.techmountain.dev {
   reverse_proxy mattermost:8065
}

Thank you

Best regards,
lemmi25

Are you certain the mail server is listening on 587? SMTPS sometimes uses 465.

Can you open a connection to that port with netcat or something? There may be a firewall issue.

Hey thanks for the fast reply. I also tried some of my other emails. Like hotmail or web and they all give me the same error.

Mattermost is trying to open a connection to port 587 and timing out waiting on a response. Either that port isn’t actually open and listening, or something is preventing your traffic from getting there. I’d start without TLS. Get just plain old SMTP on port 25 working with something. Then make sure you have the correct info for whichever server you’re using.

Hey,

I can send something to port 578 on my mailserver.
Could this be an issue with my reverse proxy?

If your proxy is configured to handle traffic on that port, yeah! That would be… odd.

Still not working. I do not get why mattermost is not able to send mails. Or times out. Can I increase the timeout time?

Increasing the timeout wouldn’t help. Mattermost cannot send emails because it cannot open the port specified.

I configured the SMTP server with the exact same settings in Thunderbird, and it works there. So, the issue shouldn’t be on that side. Am I missing something?

On the same host?

On the Mattermost server, can you nc 162.55.254.207 587 and get a response?

If so, this might be an SELinux thing. Tail out your /var/log/syslog or /var/log/messages while you try the test in Mattermost.

Many thanks for your help. I solved it by setting the Firewall rules correctly. Port 587 was not open.

1 Like