alertmanager icon indicating copy to clipboard operation
alertmanager copied to clipboard

If I customize the SSL/TLS port, how should Alertmanager support?

Open Gintoms opened this issue 1 month ago • 2 comments

Summary

The current email notification implementation has hardcoded logic that only enables direct TLS connections for port 465. This creates a limitation when using TLS on other ports, causing create SMTP client: EOF errors when the server expects TLS connections on non-465 ports.

Description

In notify/email/email.go:133, there's hardcoded logic that only uses tls.Dial() for port 465, while all other ports use plain TCP connections. This causes issues when SMTP servers require TLS connections on ports other than 465.

However, some SMTP servers may be configured to require TLS connections on non-standard ports but don't support STARTTLS, leading to EOF errors.

Gintoms avatar Nov 20 '25 06:11 Gintoms

Hi, thanks for looking into this issue! Allowing tls over non-standard ports seems like a very reasonable feature.

I think the best way to do this would be a new field in EmailConfig (https://github.com/prometheus/alertmanager/blob/main/config/notifiers.go#L300-L317) that "forces" TLS. This way, we can keep the existing behavior where we assume a TLS connection is required if the port is 465 while allowing users to configure TLS for other ports.

What do you think of that plan? Would you be interested in contributing this change?

Spaceman1701 avatar Nov 20 '25 23:11 Spaceman1701

Hi, thanks for looking into this issue! Allowing tls over non-standard ports seems like a very reasonable feature.

I think the best way to do this would be a new field in EmailConfig (https://github.com/prometheus/alertmanager/blob/main/config/notifiers.go#L300-L317) that "forces" TLS. This way, we can keep the existing behavior where we assume a TLS connection is required if the port is 465 while allowing users to configure TLS for other ports.

What do you think of that plan? Would you be interested in contributing this change?

Sounds good!

Gintoms avatar Nov 21 '25 03:11 Gintoms