[JIRA] (JENKINS-58813) Cannot send Email notification over office365 smtp with starttls has no effect

19 views
Skip to first unread message

t.krisztian95@gmail.com (JIRA)

unread,
Aug 5, 2019, 9:22:02 AM8/5/19
to jenkinsc...@googlegroups.com
Krisztián Gyula Tóth created an issue
 
Jenkins / Bug JENKINS-58813
Cannot send Email notification over office365 smtp with starttls has no effect
Issue Type: Bug Bug
Assignee: Adrien Lecharpentier
Components: mailer-plugin
Created: 2019-08-05 13:21
Environment: Jenkins ver. 2.187, Ubuntu 18.04
Priority: Minor Minor
Reporter: Krisztián Gyula Tóth

I migrated our Jenkins server from an Ubuntu 16.04 VPS to another 18.04. I installed Jenkins via apt on the new server first and then rsync all the files and config from the old one. Everything looks working fine.

But, email notifications not.

  •  SMTP server : smtp.office365.com
  • Use SMTP Authentication : checked
    • "User name" match with the "System Admin e-mail address"
  • Use SSL : unchecked
  • SMTP Port : 587

I modified the "/etc/default/jenkins" file, added line

  • JAVA_ARGS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"

But when I try to run "Test configuration" I got the given error message below:

"Failed to send out e-mail"

StackTrace

java.net.SocketException: Connection closed by remote host
	at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1547)
	at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:71)
	at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:114)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
	at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2104)
Caused: javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
	java.net.SocketException: Connection closed by remote host
	at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2106)
	at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2093)
	at com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:1184)
	at javax.mail.Transport.send0(Transport.java:197)
	at javax.mail.Transport.send(Transport.java:124)
	at hudson.tasks.Mailer$DescriptorImpl.doSendTestMail(Mailer.java:613)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
	at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
	at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
	at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:535)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
	at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:280)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:676)
	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
	at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:243)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.locale.LocaleFilter.doFilter(LocaleFilter.java:42)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:128)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:99)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1700)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1667)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:505)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:698)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:804)
	at java.lang.Thread.run(Thread.java:748)

What I tried to do:

  • Restart Jenkins multiple times (Through GUI and from command line as well)
  • Add line "JENKINS_JAVA_OPTIONS="-Dmail.smtp.starttls.enable=true"" to "/etc/default/jenkins"
  • Under Script Console run command "System.setProperty("mail.smtp.starttls.enable","true")"
  • Try enable and disable SSL and port 467

 

So, the settings under E-mail notification section are all the same as on the old server with version 2.176.2.

 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

t.krisztian95@gmail.com (JIRA)

unread,
Aug 5, 2019, 9:28:06 AM8/5/19
to jenkinsc...@googlegroups.com
Krisztián Gyula Tóth updated an issue
I migrated our Jenkins server from an Ubuntu 16.04 VPS to another 18.04. I installed Jenkins via apt on the new server first and then rsync all the files and config from the old one. Everything looks working fine.

But, email notifications not.
*  SMTP server : smtp.office365.com
* Use SMTP Authentication : checked
** "User name" match with the "System Admin e-mail address"
* Use SSL : unchecked
* SMTP Port : 587


I modified the "/etc/default/jenkins" file, added line
* JAVA_ARGS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"


But when I try to run "Test configuration" I got the given error message below:

"Failed to send out e-mail"
h3. {color:# FF0000 ff0000 }StackTrace{color}
{code:java}
{code}
What I tried to do
too :
* Restart Jenkins multiple times (Through GUI and from command line as well)
* Add line "JENKINS_JAVA_OPTIONS="-Dmail.smtp.starttls.enable=true"" to "/etc/default/jenkins"
* Under Script Console run command "System.setProperty("mail.smtp.starttls.enable","true")"
* Try enable and disable SSL and
change port 467

 

So, the settings under
the E-mail notification section are all the same as on the old server with Jenkins version 2.176.2. For me it looks like the "-Dmail.smtp.starttls.enable=true" has no effect or maybe this line looks interesting for me at the stack trace "at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:99)".

What could cause the problem?

 

 

t.krisztian95@gmail.com (JIRA)

unread,
Sep 16, 2019, 3:41:02 AM9/16/19
to jenkinsc...@googlegroups.com
Krisztián Gyula Tóth commented on Bug JENKINS-58813
 
Re: Cannot send Email notification over office365 smtp with starttls has no effect

Somehow I got the emails to my inbox now.  I restarted Jenkins and both the host machine several times and updated Jenkins version too. But when I test email configuration by 'Test configuration by sending test e-mail' from Manage Jenkins > Configure System > E-mail notification section. I've got the following error below:

javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [AM0PR0202CA0008.eurprd02.prod.outlook.com]

	at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:809)
	at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:752)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669)
	at javax.mail.Service.connect(Service.java:317)
	at javax.mail.Service.connect(Service.java:176)
	at javax.mail.Service.connect(Service.java:125)
	at javax.mail.Transport.send0(Transport.java:194)
	at javax.mail.Transport.send(Transport.java:124)
	at hudson.tasks.Mailer$DescriptorImpl.doSendTestMail(Mailer.java:671)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
	at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
	at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
	at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:535)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
...

My thought was about why the emails arrive despite test fails it's because I use the 'Extended E-mail Notification' plugin in my Jobs but the 'E-mail notification' still looks like not working.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

paul@zot.org (JIRA)

unread,
Sep 23, 2019, 11:57:02 PM9/23/19
to jenkinsc...@googlegroups.com

I had exactly the same problem with the same stack trace, same Jenkins version, and same configuration steps, and it required two things to fix it:

1) upgrading the Mailer plugin from v1.24 to v1.28

2) the sysadmin email address MUST match the sending SMTP user. I tried making it another valid user on the same domain, but that didn't work. A lot of people online say that it just needs to be another valid account, but from what I could see, it didn't work until they matched. So now I have a 'noreply' user as the system admin's email address in Jenkins

tommy@sparber.net (JIRA)

unread,
Sep 26, 2019, 7:24:02 AM9/26/19
to jenkinsc...@googlegroups.com

This should be fixed with the PR 67 once it is approved, merged and released.

mesika.guy@gmail.com (JIRA)

unread,
Oct 29, 2019, 3:26:03 AM10/29/19
to jenkinsc...@googlegroups.com

Has the same issue exactly

upgrade the mailer plugin to 1.29

rakeshcse590@gmail.com (JIRA)

unread,
Apr 27, 2020, 11:46:03 AM4/27/20
to jenkinsc...@googlegroups.com
Rakesh S updated an issue
 
Change By: Rakesh S
Attachment: jenkinsError.png
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

rakeshcse590@gmail.com (JIRA)

unread,
Apr 27, 2020, 11:46:05 AM4/27/20
to jenkinsc...@googlegroups.com

rakeshcse590@gmail.com (JIRA)

unread,
Apr 27, 2020, 11:46:08 AM4/27/20
to jenkinsc...@googlegroups.com
Rakesh S commented on Bug JENKINS-58813
 
Re: Cannot send Email notification over office365 smtp with starttls has no effect

hi Guy Mesika/Adrien Lecharpentier,

I am working on windows 7 machine, i have configured below but still getting the same error 

  1. extended email notification with smtp.office365.com, unchecked SSl, Port 587
  2. upgraded mailer plug in to 1.29 
  3. added -Dmail.smtp.starttls.enable=true to JAVA_HOME arguments in jenkins.xml file 

When I am checking "Test configuration by sending test e-mail" getting error message as "javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [BMXPR01CA0071.INDPRD01.PROD.OUTLOOK.COM]"

Attached the screenshots

 

Thanks,

Rakesh

rakeshcse590@gmail.com (JIRA)

unread,
Apr 27, 2020, 11:47:02 AM4/27/20
to jenkinsc...@googlegroups.com
Rakesh S edited a comment on Bug JENKINS-58813
hi [~gmesika]/[~alecharp],


I am working on windows 7 machine, i have configured below but still getting the same error 
# extended email notification with smtp.office365.com, unchecked SSl, Port 587
# upgraded mailer plug in to 1.29 
# added -Dmail.smtp.starttls.enable=true to JAVA_HOME arguments in jenkins.xml file 


When I am checking "Test configuration by sending test e-mail" getting error message as "javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [BMXPR01CA0071.INDPRD01.PROD.OUTLOOK.COM]"

!jenkinsError.png!!jenkinsError2.JPG!

Attached the screenshots
. Could you please help.

 

Thanks,

Rakesh
Reply all
Reply to author
Forward
0 new messages