try {
$credentials = new-object Management.Automation.PSCredential “ad@foc.ru”, (“dasfkjaehj5” | ConvertTo-SecureString -AsPlainText -Force)
$mailParams = @{
'To' = "prices@mits.ru"
'From' = "ad@foc.ru"
'Encoding' = 'UTF8'
'Subject' = "340."
'Body' = "Сообщение отправлено автоматически"
'Smtpserver' = "mail.foc.ru"
'Port' = 25
'Attachments' = "E:\FTP\EMEX\price_forceauto.csv"
'Credential' = $credentials
}
Send-MailMessage @mailParams -ErrorAction Stop
}
catch {
$errorMessage = "Error sending email: $($_.Exception.Message)"
Write-Warning $errorMessage
Add-Content -Path 'E:\FTP\EMEX\error.txt' -Value $errorMessage
}
我们收到一个错误:
Error sending email: The SMTP server required a secure connection, or the client was not authenticated. Server Response: 5.7.1 Local mailbox price@avto-olimp.com not found.**