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!<\/p>\n
Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
\nAt line:4 char:1<\/p>\n
<\/code><\/pre>\n<\/li>\n- CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException<\/li>\n
- FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage<\/li>\n<\/ul>","upvoteCount":4,"answerCount":4,"datePublished":"2022-02-25T13:35:14.000Z","author":{"@type":"Person","name":"chaz82","url":"https://community.spiceworks.com/u/chaz82"},"suggestedAnswer":[{"@type":"Answer","text":"
Advertisement
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!<\/p>\n
Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
\nAt line:4 char:1<\/p>\n
\n- Send-MailMessage -From “[email protected]<\/a>” -To \"chaz.bu …<\/li>\n
- \n
<\/code><\/pre>\n<\/li>\n- CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException<\/li>\n
- FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage<\/li>\n<\/ul>","upvoteCount":4,"datePublished":"2022-02-25T13:35:14.000Z","url":"https://community.spiceworks.com/t/send-email-in-powershell/826126/1","author":{"@type":"Person","name":"chaz82","url":"https://community.spiceworks.com/u/chaz82"}},{"@type":"Answer","text":"
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<\/a> .<\/p>\nSend-MailMessage (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn<\/a> Send-MailMessage (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn<\/a><\/p>\nDE0005: SmtpClient shouldn't be used\nMotivation\n\nSmtpClient 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.\nRecommendation\n\nUse MailKit or other libraries.\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2022-02-25T13:51:16.000Z","url":"https://community.spiceworks.com/t/send-email-in-powershell/826126/2","author":{"@type":"Person","name":"saidbrandon","url":"https://community.spiceworks.com/u/saidbrandon"}},{"@type":"Answer","text":"Here’s a link to installing and using Mailkit<\/a><\/p>\n