Hey Folks, I have been trying to use the 'Send-MailMessage API to send emails and getting the error below.
Send-MailMessage : The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.7.57 Client not authenticated to send mail. Error: 535
5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant. Visit
Enable or disable SMTP AUTH in Exchange Online | Microsoft Learn for more information. [SJ0PR03CA0222.namprd03.prod.outlook.com]
At C:\vmal\Compute-Fabric-HostAgent\src\scripts\Email.ps1:36 char:19
- … $unused = Send-MailMessage -To $To -From $from -SmtpServer $SMTPSer …
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-Mai
lMessage], SmtpException - FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
- CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-Mai
On following the steps to enable SMTP Auth as mentioned in Enable or disable SMTP AUTH in Exchange Online | Microsoft Learn, I installed the ExchangeOnlineManagement module by using the command ‘Install-Module -Name ExchangeOnlineManagement’ and post that trying to use the command ‘Set-TransportConfig -SmtpClientAuthenticationDisabled $false’ but get the following error:
Set-TransportConfig -SmtpClientAuthenticationDisabled $false
Set-TransportConfig : The term ‘Set-TransportConfig’ is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:1
- Set-TransportConfig -SmtpClientAuthenticationDisabled $false
-
+ CategoryInfo : ObjectNotFound: (Set-TransportConfig:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Any idea why this error is showing up and how it can be resolved? Any more modules to be installed? I didnt find any in the documentation…
Thanks
Monisha