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)
        ... (truncated)
        at java.base/java.lang.Thread.run(Thread.java:840)
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)
        ... (truncated)

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.