Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

Powershell sen-mailmessage script doesnt work

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...