mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #13030 from appwrite/fix/doctor-smtp-no-send
fix: stop doctor SMTP check from sending live email
This commit is contained in:
1 file changed
+14
-13
@@ -14,8 +14,6 @@ use Utopia\Domains\Domain;
|
||||
use Utopia\DSN\DSN;
|
||||
use Utopia\Http\Http;
|
||||
use Utopia\Logger\Logger;
|
||||
use Utopia\Messaging\Adapter\Email as EmailAdapter;
|
||||
use Utopia\Messaging\Messages\Email as EmailMessage;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Pools\Group;
|
||||
use Utopia\Queue\Broker\Pool as BrokerPool;
|
||||
@@ -222,20 +220,23 @@ class Doctor extends Action
|
||||
}
|
||||
}
|
||||
|
||||
// Probe SMTP reachability only; do not send a live message.
|
||||
try {
|
||||
/** @var EmailAdapter $smtp */
|
||||
$smtp = $register->get('smtp');
|
||||
$smtpHost = System::getEnv('_APP_SMTP_HOST', '');
|
||||
$smtpPort = (int) System::getEnv('_APP_SMTP_PORT', '25');
|
||||
|
||||
$emailMessage = new EmailMessage(
|
||||
to: ['demo@example.com'],
|
||||
subject: 'Test SMTP Connection',
|
||||
content: 'Hello World',
|
||||
fromName: \urldecode(System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server')),
|
||||
fromEmail: System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM),
|
||||
);
|
||||
if ($smtpHost === '') {
|
||||
Console::log('⚪ ' . str_pad("SMTP", 50, '.') . 'not configured');
|
||||
} else {
|
||||
$connection = @\fsockopen($smtpHost, $smtpPort > 0 ? $smtpPort : 25, $errno, $errstr, 3);
|
||||
|
||||
$smtp->send($emailMessage);
|
||||
Console::success('🟢 ' . str_pad("SMTP", 50, '.') . 'connected');
|
||||
if ($connection !== false) {
|
||||
\fclose($connection);
|
||||
Console::success('🟢 ' . str_pad("SMTP", 50, '.') . 'connected');
|
||||
} else {
|
||||
Console::error('🔴 ' . str_pad("SMTP", 47, '.') . 'disconnected');
|
||||
}
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
Console::error('🔴 ' . str_pad("SMTP", 47, '.') . 'disconnected');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user