Share via

SMTP Authenticaion Error

Mahesh Jaiswal 86 Reputation points
2021-09-02T05:49:08.17+00:00

Dear All,

We I am getting below error while running PowerShell script which used to send password expiry notification to the AD user on PowerShell ISE. It is showing below error once run the script. We are not having specific SMTP server setup in our environment we are using SMTP global service of Office365.
Where SMTP server is : SMTP.office365.com and Port number is = 587

"Exception calling "Send" with "1" argument(s): "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. [BMXPR01CA0063.INDPRD01.PROD.OUTLOOK.COM]"

Requesting you to please let me know how to resolve this issue. Is it compulsory to have SMTP server setup for this script to run without error or how to use Global SMTP service for the same.

NOTE: Currently I am testing this from my domain system and also check on AD server but received same error.

Thanks and Best Regards.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | Other
0 comments No comments

Answer accepted by question author

Limitless Technology 40,106 Reputation points
2021-09-02T11:59:37.85+00:00

Hello @Mahesh Jaiswal ,

The main difference betwen the "classic" way (through a SMTP server in the Domain) and O365 is that the Domain SMTP would allow running with the script run credentials, while O365 will require authentication for each run.

For example: if you add the variable "$Cred = Get-Credential" will prompt for the O365 mailbox credentials and your script should run smoothly this time.

There are 2 methods to allow applications or services to
AUTH Submission
DirectSend

Both are very well explained and implementation detailed in this article:
https://learn.microsoft.com/en-us/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365

Unless this is a vital service for a full application of service that is based upon SMTP through O365 to work, I would recommend to build up a simple SMTP server in the domain, for the purpose, as it should be faster to deploy and manage.

Hope this help you!
Best regards,

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.