Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| отправка_почты_из_powershell [2026/09/08 14:23] – jp | отправка_почты_из_powershell [2026/11/20 09:00] (current) – jp | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| Данный // | Данный // | ||
| + | |||
| + | :!: // | ||
| < | < | ||
| Line 37: | Line 39: | ||
| -Subject "Test message" | -Subject "Test message" | ||
| -Body "Test SMTP message from PowerShell" | -Body "Test SMTP message from PowerShell" | ||
| + | </ | ||
| + | |||
| + | ==== Отправка через Postfix по 465 с AUTH LOGIN ==== | ||
| + | |||
| + | < | ||
| + | $SmtpServer = " | ||
| + | $Username | ||
| + | $From = " | ||
| + | $To = " | ||
| + | |||
| + | $Message = @" | ||
| + | From: < | ||
| + | To: <$To> | ||
| + | Subject: Postfix SMTP test | ||
| + | MIME-Version: | ||
| + | Content-Type: | ||
| + | Content-Transfer-Encoding: | ||
| + | |||
| + | Test message sent through Postfix on port 465 with authentication. | ||
| + | "@ | ||
| + | |||
| + | $TempFile = [System.IO.Path]:: | ||
| + | |||
| + | try { | ||
| + | # UTF-8 без BOM, переводы строк CRLF | ||
| + | $Message = $Message -replace ' | ||
| + | [System.IO.File]:: | ||
| + | $TempFile, | ||
| + | $Message + " | ||
| + | [System.Text.UTF8Encoding]:: | ||
| + | ) | ||
| + | |||
| + | $CurlArgs = @( | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | & curl.exe @CurlArgs | ||
| + | |||
| + | if ($LASTEXITCODE -ne 0) { | ||
| + | throw " | ||
| + | } | ||
| + | |||
| + | Write-Host " | ||
| + | } | ||
| + | finally { | ||
| + | Remove-Item -LiteralPath $TempFile -Force -ErrorAction SilentlyContinue | ||
| + | } | ||
| </ | </ | ||
| {{tag> | {{tag> | ||