You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins邮件扩展插件连接Office365 SMTP报501 5.5.4域名无效错误

问题描述

使用Jenkins Email Extension插件通过Office365 SMTP服务器发送失败流水线的邮件通知时,触发501 5.5.4 Invalid domain name错误,EHLO/HELO命令后附带乱码,无法找到配置SMTP客户端主机名的入口。

报错日志
Successfully created MimeMessage
Sending email to: scoots@website.com
DEBUG: getProvider() returning jakarta.mail.Provider[TRANSPORT,smtp,org.eclipse.angus.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp-mail.outlook.com, user=jenkins, password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.office365.com", port 587, isSSL false
220 BN9PR03CA0850.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 29 Aug 2024 20:27:00 +0000 [08DCC75C8712D891]
DEBUG SMTP: connected to host "smtp.office365.com", port: 587
EHLO internalr8.internal���������������
501 5.5.4 Invalid domain name [BN9PR03CA0850.namprd03.prod.outlook.com 2024-08-29T20:27:06.007Z 08DCC75C8712D891]
HELO internalr8.internal���������������
501 5.5.4 Invalid domain name [BN9PR03CA0850.namprd03.prod.outlook.com 2024-08-29T20:27:11.007Z 08DCC75C8712D891]
MessagingException message: 501 5.5.4 Invalid domain name [BN9PR03CA0850.namprd03.prod.outlook.com 2024-08-29T20:27:11.007Z 08DCC75C8712D891]
排查信息
  • 已通过命令行swak成功发送测试邮件,说明SMTP服务器正常,且服务器主机名可正常配合使用
  • /etc/hosts中同一IP对应多个FQDN:
XX.X.X.XX       internalr8.internal                internal-alias      internal.internal
  • Jenkins地址为https://internal.internal/
  • Jenkins配置的JENKINS_JAVA_OPTIONS:"JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true""
解决方法
  • 强制指定SMTP客户端主机名
    修改Jenkins的JENKINS_JAVA_OPTIONS,添加-Dmail.smtp.localhost=internal.internal参数,强制JavaMail使用合法的主机名发送EHLO/HELO命令,修改后配置如下:

    JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true -Dmail.smtp.localhost=internal.internal"
    

    修改完成后重启Jenkins生效。

  • 检查Email Extension插件高级配置
    进入Jenkins系统配置的「Extended E-mail Notification」模块,展开高级设置,查看是否存在自定义HELO/EHLO主机名的选项,若有直接填入internal.internal。

  • 修复系统主机名编码问题
    执行hostname命令检查服务器主机名输出是否存在乱码:

    • 若输出异常,可临时执行hostname internal.internal修改当前主机名(重启后失效,需通过系统配置工具永久修改)
    • 若系统主机名本身存在编码错误,联系IT团队修正主机名配置

内容的提问来源于stack exchange,提问作者scoots

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 18:40:14