I have a few powershell scripts that are running on a server which use the Send-MailMessage command and out of nowhere the server stopped sending emails and returned the code below. If i run the scripts on a different server or computer the script works as intended and it use to work on the now broke server aswell. I seen alot of people saying it was the password or username but it works on other devices so i do not beleive that is the issue. TIA!

Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
At line:4 char:1

  • Send-MailMessage -From “chaz.bush@monterey-blackfin.com” -To "chaz.bu …
  • CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
  • FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
4 Spice ups

The Send-MailMessage cmdlet is obsolete. This cmdlet does not guarantee secure connections to SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage. For more information, see Platform Compatibility note DE0005 .

Send-MailMessage (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn Send-MailMessage (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn

DE0005: SmtpClient shouldn't be used
Motivation

SmtpClient doesn't support many modern protocols. It is compat-only. It's great for one off emails from tools, but doesn't scale to modern requirements of the protocol.
Recommendation

Use MailKit or other libraries.

Here’s a link to installing and using Mailkit

And a module to act as a wrapper PowerShell Gallery | Send-MailKitMessage 3.2.0

Could it have to do with TLS deprecation? Does this one server have a different level of TLS configured from the others?
We recently had a struggle with outbound mail that went through an on-prem mail relay to M365. Some messages went right through, some delayed for a few hours, no rhyme or reason.
Turns out that MS was/is rolling out TLS version updates and some M365 servers had it and some did not. When the mail relay hit an M366 server that was not yet updated the message went though, when it hit an updated one the message failed and was retried some time later.