From d5b015d71a0aaf0f40beb89cfcedc75204499827 Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Tue, 10 Mar 2026 23:44:47 +0200 Subject: [PATCH] =?UTF-8?q?Lis=C3=A4=C3=A4=20fallback-ketju=20SMTP-tunnuks?= =?UTF-8?q?ille?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jos smtp_user on tyhjä, käytetään imap_useria, sitten smtp_from_emailia. Jos smtp_password on tyhjä, käytetään imap_passwordia. Korjaa tilanteen jossa imap_user-kenttä on tyhjä mutta salasana ja asetukset ovat oikein. Co-Authored-By: Claude Opus 4.6 --- api.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api.php b/api.php index f26b2c7..ac98c5e 100644 --- a/api.php +++ b/api.php @@ -646,8 +646,13 @@ function smtpCode(string $resp): string { function sendViaSMTP(string $to, string $subject, string $body, string $fromEmail, string $fromName, string $inReplyTo, string $references, array $mailbox, string $cc): bool { $host = $mailbox['smtp_host']; $port = (int)($mailbox['smtp_port'] ?? 587); + // Fallback-ketju käyttäjälle: smtp_user → imap_user → smtp_from_email $user = $mailbox['smtp_user'] ?? ''; + if ($user === '') $user = $mailbox['imap_user'] ?? ''; + if ($user === '') $user = $fromEmail; + // Fallback salasanalle: smtp_password → imap_password $pass = $mailbox['smtp_password'] ?? ''; + if ($pass === '') $pass = $mailbox['imap_password'] ?? ''; $encryption = $mailbox['smtp_encryption'] ?? 'tls'; $log = []; // Debug-loki