Failed to send out e-mail

I am trying to set up the email notification push in Jenkins. Getting error: Connection closed by remote host
	at Source)
	at Source)
	at com.sun.mail.util.TraceOutputStream.write(
	at Source)
	at Source)
	at com.sun.mail.smtp.SMTPTransport.sendCommand(
Caused: javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is: Connection closed by remote host

I have added “-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true” in jenkins.xml arguments section and restarted the jenkins.

Extended E-mail Notification Settings:
SMTP Server:
SMTP Port: 25 [tried with 587]
Use SSL: no
Use TSL: yes
Charset UTF-8

Same setting used under “E-mail Notification” settings as well

So can’t really help much on the jenkins side, thats just a generic “couldn’t make the connection” or more likely “other server closed the connection” error.

That being said, since you mentioned office365, I know they have a local binary you can run so you smtp to that localhost, then it submits to office365 via api. It apparently works a lot better.

How to set up a multifunction device or application to send email using Microsoft 365 or Office 365 | Microsoft Docs maybe? I don’t use office365 myself so I don’t know.

Unfortunately, troubleshooting of mail issues is difficult since logging is inadequate.

Can you create a custom log recorder with the following setting:

com.sun.mail.smtp.protocol at the FINEST level

After configuring the log recorder, please try sending mail and log recorded should post very detailed information.