$EmailSmtpServer = "smtp.domain.com"
$EmailFrom = "email@domain.com"
$EmailTo = "email@domain.com"
$EmailSubject = "Subject"
$EmailBody = "Body"
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$EmailSubject,$EmailBody)
$SMTPClient = New-Object Net.Mail.SmtpClient($EmailSmtpServer, 465)
$SMTPClient.EnableSsl = $false
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("Username", "Password");
$SMTPClient.Send($SMTPMessage)
Я получаю следующее сообщение об ошибке:
Exception calling "Send" with "1" argument(s): "Failure sending mail."
At line:10 char:1
+ $SMTPClient.Send($SMTPMessage)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SmtpException