Send-MailMessage - Unable to read data from the transport connection
I was having issues with emails for my various backup scripts not sending emails with my submodule, I was seeing hit or miss results but I mostly disregarded them intending to resolve the issue down the road. This issue came to a head when I noticed my Smart Card expiration notices at work had stopped sending, but all my password expiration notices were working fine.
Logs
Checking the logs I saw Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
each time an email tried to send with Send-MailMessage
. I was able to run the same command from my workstation just fine though.
Fix
My password expiration notices are sent from a Windows 10 machine, while my machines that have email issues are all running Server 2016. Once I started searching this up (and once I added a trusty site:reddit.com
) I came across a fix.
Once I added [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
into my scripts this issue was resolved.