From cc51f4243081efaa70cf9dfac87648e1d9f58195 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 20 May 2026 11:40:23 +0530 Subject: [PATCH] fix: allow SMTP connection test without senderEmail --- .../Modules/Project/Http/Project/SMTP/Update.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/SMTP/Update.php b/src/Appwrite/Platform/Modules/Project/Http/Project/SMTP/Update.php index 47a533ebf9..3b73c7b1d8 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/SMTP/Update.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/SMTP/Update.php @@ -120,16 +120,18 @@ class Update extends Action // Validate SMTP credentials // Validate when the caller is explicitly enabling or hasn't expressed a preference // (so a credentials-only PATCH can auto-enable). Skip only when the caller is - // explicitly keeping/turning SMTP off, or when senderEmail is not yet configured - // (no valid From address means no connection test is possible). - if ((\is_null($enabled) || $enabled === true) && !empty($smtp['senderEmail'] ?? '')) { + // explicitly keeping/turning SMTP off. + if (\is_null($enabled) || $enabled === true) { $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = $smtp['host'] ?? ''; $mail->Port = $smtp['port'] ?? ''; $mail->SMTPSecure = $smtp['secure'] ?? ''; - $mail->setFrom($smtp['senderEmail'], $smtp['senderName'] ?? ''); + + if (!empty($smtp['senderEmail'] ?? '')) { + $mail->setFrom($smtp['senderEmail'], $smtp['senderName'] ?? ''); + } if (!empty($smtp['username'] ?? '')) { $mail->SMTPAuth = true;