Hi,
I want to create a Powershell script to send an email to my O365 mailbox when MFA is enabled. Eventually this script will be run from different applications as from a UPS application.
I am using Direct Send to O365. I am sure all the parameters are good. I receive as error: "Mailbox unavailable. The server response was: 5.7.1 Service ....".
Can someone tell me what I am doing wrong?
My Powershell script:
Create credentials
$username = "xxxxxx@YY "
$password = "pppppppp"
$myPwd = ConvertTo-SecureString -string $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -argumentlist $username, $myPwd
Build email parameters
$mailParams = @{
SmtpServer = 'xxxxxxxx.mail.protection.outlook.com'
Port = '25'
UseSSL = $true
From = 'xxxxxx@YY '
To = 'xxxxxx@YY '
Subject = "Subject: Test Direct send "
Body = "Body: Direct send"
Credential = $cred
}
Send the email
Send-MailMessage @mailParams