Unable to send email using Power Shell

Copper Contributor

I am trying to send a mail message using Power Shell


I am using the following script:

$credential = Get-Credential


$mailParams = @{
SmtpServer = ''
Port = '587' # or '25' if not using TLS
UseSSL = $true ## or not if using non-TLS
Credential = $credential
From = 'email address removed for privacy reasons'
To = 'email address removed for privacy reasons'
Subject = "SMTP Client Submission - $(Get-Date -Format g)"
Body = 'This is a test email using SMTP Client Submission'
DeliveryNotificationOption = 'OnFailure', 'OnSuccess'

## Send the message
Send-MailMessage @mailParams


The credentials are entered in a dialog box and are my email and password which I have verified. The email box has Authenticated SMPT checked.

This is the error message I get. Any suggestions?


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, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [CH0P221CA0037.NAMP221.PROD.OUTLOOK.COM]

4 Replies
best response confirmed by StuartBT (Copper Contributor)


Please check security defaults or MFA was enabled for your tenant and mailbox?

It was the MFA
Is it possible to disable MFA on a non-people account? I am getting the exact same error.
How can I disable MFA on a service account when I do not have Admin rights?