Sporadically I get:
Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
At line:1 char:1
+ Send-MailMessage -to "kcadmin@receptrx.com" -from "kcadmin@receptrx.c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept
ion
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
When trying to send emails from a Windows 2016 Server (set up in vSphere).
Sending emails from/to the same domain. Used:
Send-MailMessage –From <O365 email address> –To <Recipient email address> –Subject "Test Email" –Body "Test SMTP Service from Powershell on Port 587" -SmtpServer smtp.office365.com -Credential $creds -UseSsl -Port 587
Send-MailMessage -From <O365 email address> -To <Recipient email address> -Subject "Test Email" -SmtpServer smtp.office365.com -Credential $creds -UseSsl -Port 587
What I have tried:
Disabled the firewall.
Created Inbound Rule for 587.
Tested Telnet and received:
451 5.7.3 STARTTLS is required to send mail [SA9PR13CA0131.namprd13.prod.outlook.com]
If I execute the same script on another server (Windows Server 2019 in vSphere, I don't get the same issues. Both servers are in the same network/domain.
Any suggestions as to what else should I try?