Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@KaparthyReddy
Copy link

What does this PR do?

This PR allows users to configure a custom test email address for the doctor command using the _APP_SMTP_TEST_EMAIL environment variable.

Why is this necessary?

The current hardcoded demo@example.com address is often rejected by SMTP providers (like SendGrid or AWS SES), causing the doctor command to report a "disconnected" status even when the configuration is correct.

Which issue does it fix?

Fixes #4952

Checklist

  • Logic updated in Doctor.php to use App::getEnv.
  • Environment variable registered in app/config/variables.php.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

This pull request makes the SMTP test email address configurable through environment variables. A new configuration variable _APP_SMTP_TEST_EMAIL is introduced in the SMTP category with a default value of demo@example.com. The Doctor task is updated to read this configuration value instead of using a hardcoded email address as the recipient when testing SMTP connectivity.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: allowing a custom SMTP test email via the _APP_SMTP_TEST_EMAIL environment variable to fix issue #4952.
Description check ✅ Passed The description clearly explains what the PR does, why it's necessary, which issue it fixes, and includes a checklist confirming the implementation approach.
Linked Issues check ✅ Passed The PR successfully addresses issue #4952 by implementing configurability of the SMTP test email address, enabling users to avoid provider-specific rejections of the hardcoded demo@example.com.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: adding the environment variable configuration and updating the Doctor.php logic to use it.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 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 44ec8de and d84a9ec.

📒 Files selected for processing (2)
  • app/config/variables.php
  • src/Appwrite/Platform/Tasks/Doctor.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: scan
🔇 Additional comments (1)
app/config/variables.php (1)

571-579: LGTM!

The configuration variable is properly structured and placed in the correct SMTP category. The description clearly explains its purpose, and the default value matches the usage in Doctor.php.

Comment on lines +217 to +218
$testEmail = App::getEnv('_APP_SMTP_TEST_EMAIL', 'demo@example.com');
$mail->addAddress($testEmail, 'Appwrite Doctor');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify the usage pattern of getEnv methods in Doctor.php and check if App::getEnv is used elsewhere in Platform Tasks

# Check all getEnv usage in Doctor.php
echo "=== All getEnv usage in Doctor.php ==="
rg -n "getEnv\(" src/Appwrite/Platform/Tasks/Doctor.php

# Check if App::getEnv is used in other Platform Tasks
echo -e "\n=== App::getEnv usage in other Platform Tasks ==="
rg -n "App::getEnv" --type=php src/Appwrite/Platform/Tasks/

# Check if System::getEnv is the standard pattern
echo -e "\n=== System::getEnv usage count in Platform Tasks ==="
rg "System::getEnv" --type=php src/Appwrite/Platform/Tasks/ | wc -l

# Check the imports at the top of Doctor.php
echo -e "\n=== Imports in Doctor.php ==="
head -30 src/Appwrite/Platform/Tasks/Doctor.php | grep -E "use |App::|System::"

Repository: appwrite/appwrite

Length of output: 3224


🏁 Script executed:

#!/bin/bash
# Check the implementations of App::getEnv and System::getEnv

echo "=== Checking Utopia\App class for getEnv method ==="
find . -type f -name "*.php" -path "*/Utopia/App*" | head -5

echo -e "\n=== Searching for App::getEnv definition ==="
rg "function getEnv" --type=php | grep -i "app\|getenv"

echo -e "\n=== Searching for System::getEnv definition ==="
rg "function getEnv" --type=php --type-add 'php:include' -A 3 | head -20

echo -e "\n=== Check if Utopia\App is used elsewhere in Doctor.php ==="
rg "App::" src/Appwrite/Platform/Tasks/Doctor.php

Repository: appwrite/appwrite

Length of output: 731


🏁 Script executed:

#!/bin/bash
# Look for Utopia library in vendor or check if we can find getEnv method definitions

echo "=== Check vendor directory for Utopia ==="
find vendor -type f -name "*.php" -path "*Utopia*" 2>/dev/null | grep -E "(App|System)" | head -10

echo -e "\n=== Search for getEnv in vendor (limited) ==="
rg "public.*function getEnv" vendor/ --type=php 2>/dev/null | head -5

echo -e "\n=== Check composer.json for Utopia version ==="
grep -A 5 "utopia" composer.json 2>/dev/null || grep -i "utopia" composer.json 2>/dev/null | head -5

echo -e "\n=== Look for any documentation or comments about getEnv in Doctor.php context ==="
sed -n '210,225p' src/Appwrite/Platform/Tasks/Doctor.php

Repository: appwrite/appwrite

Length of output: 2733


🏁 Script executed:

#!/bin/bash
# Find Utopia App and System classes with getEnv methods

echo "=== Find Utopia\App class with getEnv ==="
find vendor/utopia-php -name "*.php" -type f | xargs grep -l "class App" | head -5

echo -e "\n=== Find Utopia\System\System class ==="
find vendor/utopia-php/system -name "*.php" -type f | head -10

echo -e "\n=== Check App class in framework ==="
cat vendor/utopia-php/framework/src/App.php | head -100 | grep -A 5 "function getEnv"

echo -e "\n=== Check System class ==="
cat vendor/utopia-php/system/src/System.php | head -150 | grep -A 5 "function getEnv"

Repository: appwrite/appwrite

Length of output: 957


🏁 Script executed:

#!/bin/bash
# Read the actual getEnv implementations

echo "=== Utopia\App::getEnv method ==="
grep -A 10 "public.*function getEnv" vendor/utopia-php/framework/src/App.php

echo -e "\n=== Utopia\System\System::getEnv method ==="
grep -A 10 "public.*function getEnv" vendor/utopia-php/system/src/System/System.php

echo -e "\n=== Full context: check if App::getEnv is static or instance method ==="
grep -B 5 "function getEnv" vendor/utopia-php/framework/src/App.php | head -15

echo -e "\n=== Full context: System::getEnv ==="
grep -B 5 "function getEnv" vendor/utopia-php/system/src/System/System.php | head -15

Repository: appwrite/appwrite

Length of output: 1142


🏁 Script executed:

#!/bin/bash
# Verify Doctor.php is a CLI task and check the actual runtime context

echo "=== Check Doctor class definition ==="
head -50 src/Appwrite/Platform/Tasks/Doctor.php | grep -E "class|extends|Action"

echo -e "\n=== Check if Platform/Action is a CLI task base class ==="
grep -r "class Action" vendor/utopia-php/platform/src/ | head -3

echo -e "\n=== Check how Platform Tasks are invoked ==="
rg "Doctor" src/ --type=php | grep -E "new Doctor|Doctor::|execute" | head -5

echo -e "\n=== Verify if _APP_SMTP_TEST_EMAIL is an actual environment variable ==="
rg "_APP_SMTP_TEST_EMAIL" . --type=php | grep -v "Doctor.php" | head -5

Repository: appwrite/appwrite

Length of output: 581


Replace App::getEnv with System::getEnv on line 217.

Line 217 uses App::getEnv, which reads from the $_SERVER superglobal. However, in CLI context (Platform Tasks), $_SERVER is not reliably populated with environment variables. The System::getEnv method correctly uses PHP's getenv() function, which is the proper way to access environment variables in CLI tasks.

All other uses in Doctor.php (40 instances) correctly use System::getEnv. This inconsistency will cause _APP_SMTP_TEST_EMAIL to always fall back to the default value 'demo@example.com' instead of reading the configured environment variable, breaking SMTP test functionality.

Change:

$testEmail = App::getEnv('_APP_SMTP_TEST_EMAIL', 'demo@example.com');

to:

$testEmail = System::getEnv('_APP_SMTP_TEST_EMAIL', 'demo@example.com');
🤖 Prompt for AI Agents
In src/Appwrite/Platform/Tasks/Doctor.php around lines 217 to 218, replace the
call to App::getEnv with System::getEnv so the SMTP test email is read from the
actual environment (getenv) in CLI context; update the single line that assigns
$testEmail to call System::getEnv('_APP_SMTP_TEST_EMAIL', 'demo@example.com')
instead of App::getEnv to match the rest of the file and ensure the configured
value is used.

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.

🐛 Bug Report: test email address cause SMTP disconnected

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.