Answer the question
In order to leave comments, you need to log in
Sending an email via Powershell. Where is the mistake?
$EmailFrom = 'почта откуда отправляю@yandex.ru'
$EmailTo = 'куда@gmail.com'
$Subject = "C:\1\1.png"
$Body = "Test_1"
$SMTPServer = 'smtp.gmail.com'
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 465)
$SMTPClient.Credentials = New-Object Net.NetworkCredential("почта", "пароль");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Answer the question
In order to leave comments, you need to log in
Port 465 - smtps. it is not supported by .net
https://docs.microsoft.com/en-us/dotnet/api/system...
here they write that StartTLS is used, which means you need to use a different port - 587
and starttls: You
$SMTPClient.EnableSsl = $true
may need more
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question