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.dispatch(StandardRequestProcessorBase.dispatchStandardMethod(StandardRequestProcessorBase.java:73)
        at com.softwarementors.extjs.djn.router.processor.standard.StandardRequestProcessorBase.dispatchStandardMethod(StandardRequestProcessorBase.dispatchStandardMethod(DispatcherBase.java:73)
        at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.processIndividualRequest(JsonRequestProcessorBase.java:502)
        at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.processIndividualRequestsInThisThread(JsonRequestProcessorBase.jsonRequestProcessor.process(JsonRequestProcessorBase.jsonRequestProcessor.processJsonRequest(JsonRequestProcessorBase.jsonRequestProcessor.processJsonRequest(JsonRequestProcessorBase.jsonRequestProcessor.processJsonRequest(JsonRequestProcessorBase.jsonRequestProcessor.processIndividualRequestsJsonRequest(dispatcherJsonRequest.JSONrequest.Base.dispatchJSON()
        at com.softwarementors.extjs.djn.router.RequestRouter.processJsonRequest(RequestRouter.java:83)
        at com.softwarementors.extjs.djn.servlet.DirectJNgineServlet.processRequest(DirectJNgineServlet.java:632)
        at com.softwarementors.extjs.djn.servlet.DirectJNgineServlet.doPost(DirectJNgineServlet.java:595)
        at org.sonatype.nexus.extdirect.internal.ExtDirectServlet.doPost(ExtDirectServlet.java: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.doService(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(ServletDefinition.service(SocketException)
        ... 135 common frames omitted
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2212)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
        at javax.mail.Service.connect(Service.java:364)
        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 org.apache.commons.mail.Email.sendMimeMessage(Email.java:1295)
        ... 135 common frames omitted
Caused by: java.net.SocketException: Connection reset
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:328)
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:355)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:808)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.readHeader(SSLSocketInputRecord.readHeader(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord.decode(SSLSocketInputRecord))
        at sun.nio.ch.NioSocketImpl$1.run(NioSocketImpl.java:3269)

## 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.