Lisää fallback-ketju SMTP-tunnuksille

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 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 23:44:47 +02:00
parent cbf2bd93c8
commit d5b015d71a

View File

@@ -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 { 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']; $host = $mailbox['smtp_host'];
$port = (int)($mailbox['smtp_port'] ?? 587); $port = (int)($mailbox['smtp_port'] ?? 587);
// Fallback-ketju käyttäjälle: smtp_user → imap_user → smtp_from_email
$user = $mailbox['smtp_user'] ?? ''; $user = $mailbox['smtp_user'] ?? '';
if ($user === '') $user = $mailbox['imap_user'] ?? '';
if ($user === '') $user = $fromEmail;
// Fallback salasanalle: smtp_password → imap_password
$pass = $mailbox['smtp_password'] ?? ''; $pass = $mailbox['smtp_password'] ?? '';
if ($pass === '') $pass = $mailbox['imap_password'] ?? '';
$encryption = $mailbox['smtp_encryption'] ?? 'tls'; $encryption = $mailbox['smtp_encryption'] ?? 'tls';
$log = []; // Debug-loki $log = []; // Debug-loki