Skip to content

fix: enable SMTP debug logging in development mode#11144

Open
AdeshGhadage wants to merge 1 commit intoappwrite:mainfrom
AdeshGhadage:fix-1390-smtp-debug-development
Open

fix: enable SMTP debug logging in development mode#11144
AdeshGhadage wants to merge 1 commit intoappwrite:mainfrom
AdeshGhadage:fix-1390-smtp-debug-development

Conversation

@AdeshGhadage
Copy link

What does this PR do?

This PR improves SMTP error visibility in the Mails worker during development by conditionally enabling PHPMailer’s SMTP debug output when _APP_ENV=development

Test Plan

  • Set _APP_ENV=development

  • Intentionally misconfigured SMTP (invalid port) to force a connection failure

  • Triggered a password recovery email

  • Verified detailed PHPMailer SMTP debug output appears in appwrite-worker-mails logs

  • Restored correct SMTP configuration and confirmed successful email delivery

  • Verified no SMTP debug output when _APP_ENV=production

Related PRs and Issues

Fixes #1390

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This change adds conditional SMTP debugging to two files when the application runs in development mode. When _APP_ENV equals development, PHPMailer's SMTPDebug property is set to true in both the mail configuration initialization and the mail worker. This enables verbose SMTP error messages during development for troubleshooting email delivery issues. Existing SMTP configuration and behavior in non-development environments remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: enabling SMTP debug logging in development mode, which directly matches the changeset's primary objective.
Description check ✅ Passed The description clearly explains the purpose of the changes and provides a detailed test plan demonstrating the feature works correctly in both development and production environments.
Linked Issues check ✅ Passed The PR fully addresses issue #1390 by conditionally enabling SMTPDebug when _APP_ENV=development in both files (registers.php and Mails.php), matching the exact requirement to improve SMTP error visibility during development.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue #1390; only four lines were added to enable SMTP debugging in development mode with no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
app/init/registers.php (1)

351-353: Consider using SMTP::DEBUG_SERVER for more useful debug output.

PHPMailer's SMTPDebug property accepts integer values, not boolean. While true coerces to 1 (DEBUG_CLIENT), this only shows messages sent by the client. For troubleshooting SMTP issues, SMTP::DEBUG_SERVER (2) is more useful as it includes server responses.

♻️ Suggested improvement
+use PHPMailer\PHPMailer\SMTP;
+
 // ... in the smtp register callback ...
 
     if (System::getEnv('_APP_ENV') === 'development') {
-        $mail->SMTPDebug = true;
+        $mail->SMTPDebug = SMTP::DEBUG_SERVER;
     }
src/Appwrite/Platform/Workers/Mails.php (1)

200-202: Same recommendation: use SMTP::DEBUG_SERVER for comprehensive debug output.

For consistency with the suggested change in registers.php and to get more useful debug information (including server responses), use the integer constant instead of boolean.

♻️ Suggested improvement

Add the import at the top of the file:

use PHPMailer\PHPMailer\SMTP;

Then update the condition:

     if (System::getEnv('_APP_ENV') === 'development') {
-        $mail->SMTPDebug = true;
+        $mail->SMTPDebug = SMTP::DEBUG_SERVER;
     }
PHPMailer SMTPDebug levels documentation

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f019120 and 940b5b9.

📒 Files selected for processing (2)
  • app/init/registers.php
  • src/Appwrite/Platform/Workers/Mails.php

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
libpng 1.6.51-r0 CVE-2025-66293 HIGH
libpng-dev 1.6.51-r0 CVE-2025-66293 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improved SMTP error logging in development

1 participant