mirror of
https://github.com/itflow-org/itflow
synced 2026-03-25 23:05:37 +00:00
Remove the reliance on php-imap extension to test imap connection in setting. Also removed the check for php-imap in the mai, parser as we use fully rely on webklex
This commit is contained in:
@@ -41,11 +41,6 @@ if ($argv[1] !== $config_cron_key) {
|
|||||||
exit("Cron Key invalid -- Quitting..");
|
exit("Cron Key invalid -- Quitting..");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check IMAP extension works/installed
|
|
||||||
if (!function_exists('imap_open')) {
|
|
||||||
exit("Email Parser: PHP IMAP extension is not installed. See https://docs.itflow.org/ticket_email_parse -- Quitting..");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get system temp directory
|
// Get system temp directory
|
||||||
$temp_dir = sys_get_temp_dir();
|
$temp_dir = sys_get_temp_dir();
|
||||||
|
|
||||||
|
|||||||
@@ -198,17 +198,32 @@ if (isset($_POST['test_email_imap'])) {
|
|||||||
validateCSRFToken($_POST['csrf_token']);
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
validateAdminRole();
|
validateAdminRole();
|
||||||
|
|
||||||
// Prepare connection string with encryption (TLS/SSL/<blank>)
|
// Autoload Composer dependencies
|
||||||
$imap_mailbox = "$config_imap_host:$config_imap_port/imap/readonly/$config_imap_encryption";
|
require_once __DIR__ . '/plugins/php-imap/vendor/autoload.php';
|
||||||
|
|
||||||
// Connect
|
// Webklex PHP-IMAP
|
||||||
$imap = imap_open("{{$imap_mailbox}}INBOX", $config_imap_username, $config_imap_password);
|
use Webklex\PHPIMAP\ClientManager;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Initialize the client manager and create the client
|
||||||
|
$clientManager = new ClientManager();
|
||||||
|
$client = $clientManager->make([
|
||||||
|
'host' => $config_imap_host,
|
||||||
|
'port' => $config_imap_port,
|
||||||
|
'encryption' => $config_imap_encryption,
|
||||||
|
'validate_cert' => true,
|
||||||
|
'username' => $config_imap_username,
|
||||||
|
'password' => $config_imap_password,
|
||||||
|
'protocol' => 'imap'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Connect to the IMAP server
|
||||||
|
$client->connect();
|
||||||
|
|
||||||
if ($imap) {
|
|
||||||
$_SESSION['alert_message'] = "Connected successfully";
|
$_SESSION['alert_message'] = "Connected successfully";
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
$_SESSION['alert_type'] = "error";
|
$_SESSION['alert_type'] = "error";
|
||||||
$_SESSION['alert_message'] = "Test IMAP connection failed";
|
$_SESSION['alert_message'] = "Test IMAP connection failed: " . $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user