Mail Ticket Parser Fix: Allow Unencrypted IMAP connections

This commit is contained in:
johnnyq 2024-10-29 13:36:30 -04:00
parent af123d3978
commit ab3d915bdc
1 changed files with 14 additions and 2 deletions

View File

@ -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) {