Running into problems trying to configure a Direct Send from PS to my O365 tenant. I’m guessing a lot of folks here also run 365, so I thought I might ask here for pointers.
PS c:\temp> Send-MailMessage -From Account@MyDomain.com -To Me@MyDomain.Com -Subject $Subject -Body $Body ` -Port 25 -UseSsl -SmtpServer "<DomainName>-com.mail.protection.outlook.com" Send-MailMessage : Unable to connect to the remote server At line:1 char:1 + Send-MailMessage -From "Account@MyDomain.com" -To "Me@MyDomain.com" ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
It’s the same thing if I use port 25 or 587, and if i send to/from a distribution list or my personal address. I can nslookup the SmtpServer name, but can’t establish a connection.
I’ve also tried creating a Connector in 365 for PowerShell to send to, but - no dice. Any ideas on what you guys would check next/make sure is correct?
EDIT: Oh - and also happens regardless of whether -UseSsl is present.