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:
5
api.php
5
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 {
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user