$Username = “@.**”
$Password = “******”
$smtp.EnableSsl = $true
#corpo mail
$to = “*******@**.”
$subject = “Results for AD Report LAST LOGON”
$body = “Script version 1.0 by Maarten Mol”
$attachment = “C:\prova.txt”
$message = New-Object System.Net.Mail.MailMessage
$message.subject = $subject
$message.body = $body
$message.to.add($to)
$message.from = $username
$message.attachments.add($attachment)
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.send($message)
—ERROR—
Exception during the “Send” argument with argument “4”: "The SMTP server requires a secure connection or the client was not authenticated. Server response: 5.7.1 The client was not authenticated"In C:\Users\Roberto.Bugatti\Desktop\invioemail\mailsender.ps1:27 car:1 + $smtp.send($to,$Username,$body,$attachment)