fix: add pre-check if imap is supported before trying to connect
This commit is contained in:
@@ -502,11 +502,28 @@ class Settings extends Page implements HasForms
|
|||||||
private function testIMAP($imap): bool
|
private function testIMAP($imap): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
// First check if IMAP extension is available
|
||||||
|
if (!function_exists('imap_open')) {
|
||||||
|
Notification::make()
|
||||||
|
->title('IMAP Extension Not Available')
|
||||||
|
->body('The PHP IMAP extension is not loaded in your web server. Please check your Herd PHP configuration or restart your server.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ZEmail::connectMailBox($imap);
|
ZEmail::connectMailBox($imap);
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
|
$errorMessage = $exception->getMessage();
|
||||||
|
|
||||||
|
// Provide more helpful error messages
|
||||||
|
if (str_contains($errorMessage, 'IMAP extension must be enabled')) {
|
||||||
|
$errorMessage = 'IMAP extension is not properly loaded in the web server. Try restarting Herd or check your PHP configuration.';
|
||||||
|
}
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Imap Error : '.$exception->getMessage())
|
->title('IMAP Error: ' . $errorMessage)
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user