From ab3d915bdca5aad1f57e0fa762c52372af52661c Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 29 Oct 2024 13:36:30 -0400 Subject: [PATCH] Mail Ticket Parser Fix: Allow Unencrypted IMAP connections --- cron_ticket_email_parser.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cron_ticket_email_parser.php b/cron_ticket_email_parser.php index c4664ced..31541993 100644 --- a/cron_ticket_email_parser.php +++ b/cron_ticket_email_parser.php @@ -348,17 +348,29 @@ function createMailboxFolder($imap, $mailbox, $folderName) { // Initialize IMAP connection $validate_cert = true; // or false based on your configuration -$imap_encryption = $config_imap_encryption; // e.g., 'ssl' or 'tls' +$imap_encryption = $config_imap_encryption; // e.g., 'ssl', 'tls', or '' (empty string) for none -$mailbox = '{' . $config_imap_host . ':' . $config_imap_port . '/' . $imap_encryption; +// Start building the mailbox string +$mailbox = '{' . $config_imap_host . ':' . $config_imap_port; + +// Only add the encryption part if $imap_encryption is not empty +if (!empty($imap_encryption)) { + $mailbox .= '/' . $imap_encryption; +} + +// Add the certificate validation part if ($validate_cert) { $mailbox .= '/validate-cert'; } else { $mailbox .= '/novalidate-cert'; } + $mailbox .= '}'; + +// Append 'INBOX' to specify the mailbox folder $inbox_mailbox = $mailbox . 'INBOX'; +// Open the IMAP connection $imap = imap_open($inbox_mailbox, $config_imap_username, $config_imap_password); if ($imap === false) {