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