0
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.**
4

1 回答 1

1

供参考...

SSL 站点现在要求您在代码中也执行此操作。

# Required for use with web SSL sites
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
于 2020-11-17T00:09:13.053 回答