无法从詹金斯发送电子邮件通知

时间:2021-01-16 21:26:38

标签: linux email jenkins smtp

我在 linux 上使用 Jenkins。

我无法通过 jenkins 发送电子邮件通知。
我已经完成了如下扩展电子邮件设置enter image description here

当我使用配置发送电子邮件时,使用 jenkins 作业如下
enter image description here
它抛出以下错误

Build step 'Invoke top-level Maven targets' marked build as failure
Sending e-mails to: my-email@live.com
ERROR: Couldn't connect to host, port: localhost, 25; timeout 60000
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout 60000;
  nested exception is:
    java.net.ConnectException: Connection refused (Connection refused)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2210)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
    at javax.mail.Service.connect(Service.java:342)
    at javax.mail.Service.connect(Service.java:222)
    at javax.mail.Service.connect(Service.java:171)
    at javax.mail.Transport.send0(Transport.java:230)
    at javax.mail.Transport.send(Transport.java:100)
    at hudson.tasks.MailSender.run(MailSender.java:130)
    at hudson.tasks.Mailer.perform(Mailer.java:176)
    at hudson.tasks.Mailer.perform(Mailer.java:139)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
    at hudson.model.Build$BuildExecution.post2(Build.java:177)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
    at hudson.model.Run.execute(Run.java:1932)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:607)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:333)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:214)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
    ... 18 more

2 个答案:

答案 0 :(得分:1)

在全局配置的“电子邮件通知”部分输入您的 SMTP 服务器信息,而不是“扩展电子邮件通知插件”部分。

您正在使用电子邮件通知“构建后”步骤。与“扩展邮件通知插件”无关,因此也不使用相应的设置。

答案 1 :(得分:0)

您是否在 Google 设置中启用了“不安全的应用”连接? 在第三个应用程序中使用谷歌帐户肯定是强制性的。