【问题标题】:Alertmanager not able send mails via port 465Alertmanager 无法通过端口 465 发送邮件
【发布时间】:2023-03-13 19:55:02
【问题描述】:

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

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

但我的客户实时使用的是 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 中做哪些更改才能使其正常工作

请提供帮助。在此先感谢

【问题讨论】:

    标签: smtp prometheus prometheus-alertmanager


    【解决方案1】:

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

    根据Google's docs,端口 465 和 587 做不同的事情:

    SSL 端口:465

    TLS/STARTTLS 端口:587

    SSL 端口从一开始就使用 TLS 连接,而 STARTTLS 端口使用普通连接,然后升级到 TLS(请参阅wiki on STARTTLS

    Alertmanager 使用 smtp.Sendmail 声明:

    SendMail 在 addr 连接到服务器,如果可能,切换到 TLS

    这意味着只有 STARTTLS 方法可用,它不能处理普通 TLS。 这使得端口 465 无法使用,默认 Go sendmail 包和警报管理器。 您必须使用端口587

    【讨论】:

    • 这意味着我不能将 465 与 alertmanager 一起使用,这是我的理解。非常感谢。
    • 确实如此。我已经把答案说得更清楚了(第一行),剩下的只是细节。
    猜你喜欢
    • 2013-07-21
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 2013-01-24
    相关资源
    最近更新 更多