我需要从Power-Shell脚本发送电子邮件,我已经尝试了很多方法,但最终以下面的错误结束,我搜索了很多网站,但我找不到Power-Shell脚本的解决方案。有什么建议??
这是我试过的那个
$ From =" sathesh@xxxx.com"
$ To =" satheshl@xxxx.com"
$ Subject =" Email Subject"
$ Body ="正文在这里"
$ SMTPServer =" mail2.xxxx.com"
Send-MailMessage -From $ From -to $ To<# - Cc $ Cc#> -Subject $ Subject -Body $ Body -SmtpServer $ SMTPServer -Credential(Get-Credential)
>**Error Message**
PS C:\Users\SATHESH\Desktop\New folder> .\mail.ps1
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Send-MailMessage : Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as
this sender
At C:\Users\SATHESH\Desktop\New folder\mail.ps1:9 char:1
+ Send-MailMessage -From $From -to $To <#-Cc $Cc#> -Subject $Subject `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept
ion
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
`