Hello,
I am trying to create a runbook in Azure Automation account, that should collect some data and in the end send them via email.
But when I define the "mail send section" like this:
$emailParams = @{
From = "******@domain.com"
To = "******@domain.com"
Subject = "Test Email"
Body = 'report'
SmtpServer = "smtp.office365.com"
Port = 587
Credential = $credential
UseSsl = $true
}
Send-MailMessage @emailParams
($credential variable contains Automation account stored credential with Global reader rights, referenced via
$Credential = Get-AutomationPSCredential -Name "Cred name"
I get following error:
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.3 Authentication unsuccessful
Account that I stored within AA credentials has valid password, I can login to portal.office.com under that identity.
What is wrong? How can I send an email from AZ runbook? What is my stored credential missing?
Many thanks,
Tomas