Forum Discussion
rbn_neu
Aug 31, 2022Copper Contributor
Send-mailmessage not working in server
Hi Folks, I'm trying to send an email via PowerShell using below code: $TLS12Protocol = [System.Net.SecurityProtocolType] 'Ssl3 , Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = ...
farismalaeb
Aug 31, 2022Steel Contributor
Timeout, are you sure that the tenant is enabled for Basic Auth.
Also make sure that the connection is allowed to connect to this port by the firewall.
Why are you using SSL3? It's dead, and Microsoft doesn't support it.
Get more info here
https://adamtheautomator.com/office-365-direct-send/
Test the connectivity by running
Test-NetConnection -ComputerName smtp.office365.com -Port 587
Also, why use the Send-MailMessage? it's obsolete and no longer supported, the cmdlet is archived. I think you need to use the Graph API to send emails.
https://helloitsliam.com/2021/10/18/sending-emails-using-microsoft-graph-powershell/
For more advance parameter of the Send-MgUserMail, check this
https://www.powershellcenter.com/2022/09/01/send-mgusermail/
raindropsdev
Sep 02, 2022Iron Contributor
Additionally, Basic Auth will be permanently disabled in 1 month, so not a good idea to start using it now.