Alertmanager 无法通过端口 465 发送邮件

Alertmanager not able send mails via port 465

我正在尝试使用 config.yml 文件中配置的凭据通过 alertmanager 发送电子邮件。

我可以使用端口 587 通过 gmail smtp 服务器发送邮件。

但实际上我的客户正在使用 465 端口,我遇到了以下错误

“第一条记录看起来不像是 tls 握手”

下面是我的配置文件

route:
 receiver: 'notifications-configuration'
#This receiver name can be any userdefined name
templates:
- '/etc/alertmanager/template/emailnotification.tmpl'

#Send the notifications to below receivers.
#There can be single as well as multiple receivers
#Here there are 2 receivers one is for mail and another is for sending notifications to some API provided
receivers:
  - name: 'notifications-configuration'
    email_configs:
       - from: 'samplemailfrom@gmail.com'
         auth_username: samplemailfrom@gmail.com'
         auth_password: 'fdsfsdfsdfsdssds'
         smarthost: 'smtp.gmail.com:587'
         auth_identity: 'samplemailfrom@gmail.com'
         tls_config:
           insecure_skip_verify: true
         to: 'samplemailto@gmail.com'

当我将此 smtp 主机更改为 customersmtphost:465 时,出现上述错误

我用谷歌搜索了这个问题并找到了很多链接,但我无法弄清楚我应该在 config.yaml 中做些什么改变才能使它起作用

请帮忙解决同样的问题.. 在此先感谢

TLDR:Alertmanager 中使用的库不支持端口 465,请使用端口 587

根据 Google's docs:

,端口 465 和 587 做不同的事情

Port for SSL: 465

Port for TLS/STARTTLS: 587

SSL 端口使用来自 get-go 的 TLS 连接,而 STARTTLS 端口使用普通连接,然后升级到 TLS(参见 wiki on STARTTLS

Alertmanager 使用 smtp.Sendmail 声明:

SendMail connects to the server at addr, switches to TLS if possible

这意味着只有 STARTTLS 方法可用,它不能处理纯 TLS。 这使得端口 465 无法使用 默认的 Go sendmail 包和 alertmanager。 您必须使用端口 587.