Setup SMTP Mail via M365 (smtp.office365.com) - Sonatype Nexus Repository / Best Practices - Sonatype Community

Setup SMTP Mail via M365 (smtp.office365.com)

post by rol.N on May 19, 2025

Hi,

I would like to setup SMTP mail via M365.

Mail verification does not work.

Failed to invoke action method: coreui_Email.sendVerification, java-method: org.sonatype.nexus.coreui.EmailComponent.sendVerification
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.office365.com:587

This is the error message when I want to send a test message with Nexus Repo.

thx

Roland

post by mpiggott on May 20, 2025

Is there a stack trace?

post by rol.N on May 20, 2025

org.sonatype.nexus.extdirect.internal.ExtDirectExceptionHandler - Failed to invoke action method: coreui_Email.sendVerification, java-method: org.sonatype.nexus.coreui.EmailComponent.sendVerification
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.office365.com:587
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1298)
        at org.apache.commons.mail.Email.send(Email.java:1282)
        at org.sonatype.nexus.internal.email.EmailManagerImpl.sendMail(EmailManagerImpl.java:306)
        at org.sonatype.nexus.internal.email.EmailManagerImpl.sendVerification(EmailManagerImpl.java:255)
        at org.sonatype.nexus.coreui.EmailComponent.sendVerification(EmailComponent.java:124)
        at com.palominolabs.metrics.guice.ExceptionMeteredInterceptor.invoke(ExceptionMeteredInterceptor.java:23)
        at com.palominolabs.metrics.guice.TimedInterceptor.invoke(TimedInterceptor.java:26)
        at org.sonatype.nexus.validation.internal.ValidationInterceptor.invoke(ValidationInterceptor.java:53)
        at org.apache.shiro.guice.aop.AopAllianceMethodInvocationAdapter.proceed(AopAllianceMethodInvocationAdapter.java:49)
        at org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor.invoke(AuthorizingAnnotationMethodInterceptor.java:68)
        at org.apache.shiro.guice.aop.AopAllianceMethodInvocationAdapter.invoke(AopAllianceMethodInvocationAdapter.java:36)
        at org.apache.shiro.guice.aop.AopAllianceMethodInvocationAdapter.proceed(AopAllianceMethodInvocationAdapter.java:49)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at com.softwarementors.extjs.djn.router.dispatcher.DispatcherBase.invokeJavaMethod(DispatcherBase.java:142)
        at com.softwarementors.extjs.djn.router.dispatcher.DispatcherBase.invokeMethod(DispatcherBase.java:133)
        at org.sonatype.nexus.extdirect.internal.ExtDirectDispatcher.invokeMethod(ExtDirectDispatcher.java:82)
        at com.softwarementors.extjs.djn.router.dispatcher.DispatcherBase.dispatchStandardMethod(StandardRequestProcessorBase.dispatchStandardMethod.java:73)
        at com.softwarementors.extjs.djn.router.processor.standard.StandardRequestProcessorBase.dispatchStandardMethod(StandardRequestProcessorBase:73)
        at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.processIndividualRequest(JsonRequestProcessorBase.jsonRequestProcessor.processIndividualRequest(JsonRequestProcessorBase:502)
        at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.processIndividualRequestsInThisThread(JsonRequestProcessorBase.processJsonRequest(JsonRequestProcessorBase:133)
        at com.softwarementors.extjs.djn.router.RequestRouter.processJsonRequest(RequestRouter.processJsonRequest(RequestRouter:83)
        at com.softwarementors.extjs.djn.servlet.DirectJNgineServlet.processRequest(DirectJNgineServlet.processRequest(DirectJNgineServlet:632)
        at com.softwarementors.extjs.djn.servlet.DirectJNgineServlet.doPost(DirectJNgineServlet.doPost(DirectJNgineServlet:595)
        at org.sonatype.nexus.extdirect.internal.ExtDirectServlet.doPost(ExtDirectServlet.doPost(ExtDirectServlet:137)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.doServiceImpl(ServletDefinition:293)
        at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.doService(ServletDefinition:283)
        at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.service(ServletDefinition:184)
        at com.google.inject.servlet.DynamicServletPipeline.service(DynamicServletPipeline.service(DynamicServletPipeline:71)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.doFilter(FilterChainInvocation:85)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.doFilter(ProxiedFilterChain:61)
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.executeChain(AdviceFilter:108)
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.doFilterInternal(AdviceFilter:137)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.doFilter(OncePerRequestFilter:154)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.doFilter(ProxiedFilterChain:66)
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.executeChain(AdviceFilter:108)
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.doFilterInternal(AdviceFilter:137)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.doFilter(OncePerRequestFilter:154)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.doFilterProxiedFilterChain:66)
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.executeChain(AdviceFilter:108)
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.doFilterProxiedFilterChain:66)
        at org.springframework.web.context.request.RequestContextListener.contextInitialized(RequestContextListener.contextInitialized(requestContextListener.java:81)
        at org.springframework.web.context.request.RequestContextListener.contextInitialized(RequestContextListener.contextInitialized(requestContextListener:81))
        at org.sonatype.nexus.security.SecurityFilter.executeChain(SecurityFilter.executeChain(SecurityFilter:96)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter$1.call(AbstractShiroFilter$1:373)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.doCall(SubjectCallable:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.call(SubjectCallable:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.execute(DelegatingSubject:387)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.doFilterInternal(AbstractShiroFilter:370)
        at org.sonatype.nexus.security.SecurityFilter.executeChain(SecurityFilter.executeChain(SecurityFilter:96)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter$1.call(AbstractShiroFilter$1:373)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.doCall(SubjectCallable:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.call(SubjectCallable:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.execute(DelegatingSubject:387)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.doFilterInternal(AbstractShiroFilter:370)
        at org.sonatype.nexus.security.SecurityFilter.executeChain(SecurityFilter.executeChain(SecurityFilter:96)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter$1.call(AbstractShiroFilter$1:373)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.doCall(SubjectCallable:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.call(SubjectCallable:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.execute(DelegatingSubject:387)
        at org.springframework.web.context.request.RequestContextListener.contextInitialized(requestContextListener:81)
        at org.springframework.web.context.request.RequestContextListener.contextInitialized(requestContextListener:81)
        at org.sonatype.nexus.security.SecurityFilter.executeChain(SecurityFilter.executeChain(SecurityFilter:96)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter$1.call(AbstractShiroFilter$1:373)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.doCall(SubjectCallable:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.call(SubjectCallable:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.execute(DelegatingSubject:387)
        at org.springframework.web.context.request.RequestContextListener.contextInitialized(requestContextListener:81)
        at org.springframework.web.context.request.RequestContextListener.contextInitialized(requestContextListener:81)
        at org.sonatype.nexus.security.SecurityFilter.executeChain(SecurityFilter.executeChain(SecurityFilter:96)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.openServer(SMTPTransport:2212)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.protocolConnect(SMTPTransport:722)
        at javax.mail.Service.connect(Service.connect(Service:364)
        at javax.mail.Service.connect(Service.connect(Service:222)
        at javax.mail.Service.connect(Service.connect(Service:171)
        at javax.mail.Transport.send0(Transport.send0(Transport:230)
        at javax.mail.Transport.send(Transport.send(Transport:100)
        at org.apache.commons.mail.Email.sendMimeMessage(Email.sendMimeMessage(Email:1295)
        ... 135 common frames omitted
Caused by: java.net.SocketException: Connection reset
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.implRead(NioSocketImpl:328)
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.read(NioSocketImpl:355)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl$1.read(NioSocketImpl$808)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.read(SocketInputStream:966)
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord:484)
        at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord:478)
        at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord:160)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport:111)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl:1510)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl:startHandshake(SSLSocketImpl:455)
        at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher:602)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher:376)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher:193)
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.openServer(SMTPTransport:2160)
        ... 142 common frames omitted

post by mpiggott on May 20, 2025

This part of the error suggests there is a network level issue which is closing the TCP connection to the mail server.

You’ll probably need to determine whether there is a firewall or similar which prevents the Nexus host from connecting to the mail server.