【问题标题】:PHP mail() is giving Network is unreachable in "Microsoft Azure VM"PHP mail() 在“Microsoft Azure VM”中给出 Network is unreachable
【发布时间】:2021-12-17 14:10:18
【问题描述】:

我正在尝试测试邮件以从我在 Microsoft Azure 的 VM 发送电子邮件,但我收到了这个错误!

Nov  3 06:33:22 devvm postfix/smtp[10942]: connect to alt1.gmail-smtp-in.l.google.com[142.250.150.27]:25: Connection timed out
Nov  3 06:33:22 devvm postfix/smtp[10942]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:4010:c1c::1b]:25: Network is unreachable
Nov  3 06:33:22 devvm postfix/smtp[10942]: connect to alt2.gmail-smtp-in.l.google.com[2404:6800:4003:c00::1b]:25: Network is unreachable
Nov  3 06:33:22 devvm postfix/smtp[10942]: 4C7CABDD84: to=MyEmailRemoved@gmail.com>, relay=none, delay=57498, delays=57437/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2404:6800:4003:c00::1b]:25: Network is unreachable)

我尝试从 azure 启用端口 25,但不知道如何解决此问题。

【问题讨论】:

  • Azure 可能会阻止您无法控制的出站 SMTP 流量 - 请查看他们的文档。此外,您应该使用端口 465 或 587 使用 PHPMailer 安全发送。

标签: php azure smtp phpmailer


【解决方案1】:

来自 VM 的出站 SMTP 连接存在限制。阻止来自 Azure 的直接 SMTP 连接,以保护 Azure 数据中心公共 IP 地址免受声誉滥用,即使经过身份验证也是如此。

只有当虚拟机部署在某些订阅类型中时,才能通过 TCP 端口 25 从虚拟机直接发送到外部域(如 outlook.comgmail.com)的外发电子邮件。

即使对于部署在即用即付订阅中的 VM,TCP 端口 25 上的出站 SMTP 连接也会被阻止。但是,如果您的 Azure 订阅信誉良好并且有足够的付款历史记录,则可以删除此阻止。您可以通过转到 Diagnose and Solve 边栏选项卡的 Cannot send email (SMTP-Port 25) 部分来请求删除限制,以获取 Azure 虚拟网络资源Azure 门户。

仅对于部署在企业协议订阅中的虚拟机,不会阻止 TCP 端口 25 上的出站 SMTP 连接。

作为一种解决方法,建议使用经过身份验证的 SMTP 中继服务从 Azure VM 发送电子邮件。这些中继服务通常通过 TCP 端口 587 连接。SendGrid 就是这样一种 SMTP 中继服务,但还有其他服务。

阅读此Sending Email with Microsoft Azure 文档,详细了解如何使用 SendGrid 从 Azure VM 发送邮件。

有关限制来自 VM 的出站 SMTP 连接的更多信息,请阅读此Troubleshoot outbound SMTP connectivity problems in Azure document

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 2017-02-17
    • 2018-08-12
    相关资源
    最近更新 更多