- This topic has 2 replies, 2 voices, and was last updated 1 month, 2 weeks ago by
May 29, 2020 at 8:54 pm #231979ParticipantTopics: 6Replies: 17Points: 132Rank: Participant
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 [email protected] -To [email protected] -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 "[email protected]" -To "[email protected]" ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 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.
- This topic was modified 1 month, 2 weeks ago by mitchvh05.
May 29, 2020 at 9:04 pm #231985ParticipantTopics: 3Replies: 431Points: 1,533Rank: Community Hero
If it’s always coming from the same network, I usually set up an IIS SMTP server to relay. It’s a lot easier to get it connecting to O365 and then you can send it simply from PS or wherever. You can allow specific IPs, hosts, users, or the entire subnet. This is also a life saver for dumb scanners, phone systems, etc that may not support TLS or specific ports. You can use user authentication from the smtp relay or what I prefer, SPF/send connector handled auth. Then you can send from any email on your tenant, whether licensed or not, as long as it’s valid.
May 29, 2020 at 9:09 pm #231988ParticipantTopics: 3Replies: 431Points: 1,533Rank: Community Hero
Option 3 on this page is what I was referring to.
Here is some info on SMTP relay
- You must be logged in to reply to this topic.