i'm writing a simple script to send email message via powershell
it pretty simple right now, i'll edit from - to - body - Subject etc with variables as soon it works...
this is my code
clear
# server smtp
$smtpserver = "smtp.xxxx.it"
# porta
$smtpport = "25"
# username completo di chiocciola
$smtpuser = "[email protected]"
# password
$smtppwd = "MyPassword"
# genero la password codificata
$secpasswd = ConvertTo-SecureString $smtppwd -AsPlainText -Force
# genero set credenziali da usare con la funzione
$smtpcreds = New-Object System.Management.Automation.PSCredential ($smtpuser, $secpasswd)
# funzione
Send-MailMessage -Body "test" -to [email protected] -from [email protected] -Subject "HOPE IT WORKS NOW" -SmtpServer $smtpserver -Port $smtpport -Credential $smtpcreds
but i always get this error
Send-MailMessage : Cassetta postale non disponibile. Risposta del server: 5.7.1 Relaying to <[email protected]> denied (authentication
required)
In C:UsersUtenteDesktopMonitorScriptQuasi OK.ps1:16 car:1
+ Send-MailMessage -Body "test" -to [email protected] -from myemail@ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpFailedRecipientException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
any help would be appreciated
question from:
https://stackoverflow.com/questions/65928791/powershell-sen-mailmessage-script-doesnt-work 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…