After moving my osTicket installation to a ubuntu 18.04 server with Php 7.2 it can't fetch mail anymore. It started giving an error about SSL negotiations, while the server doesn't require nor accept SSL and SSL isn't selected in the osTicket settings. The error that shows up in the settings now is: TLS/SSL failure for mail.simplycode.nl: SSL negotiation failed

As reference, the settings from the email hosting and osTicket settings pages are added below:


Has anyone else encountered this error and found a solution or an idea on what might be causing this?

I was using the theme from https://osticketawesome.com/ and thought there might be an issue in it. However even after reverting to a fully stock install, the error persists.

Found it, there seems to be a bug in the mail fetcher in 1.12.2. The connection string for the mailbox doesn't get formatted correctly when not using SSL.

For who finds this on Google, here's is how I made it work;
In the include directory of your osTicket installation, edit class.mailfetch.php. Around line 60 you'll find the Mail server string section.

I've changed it to this:

            //Mail server string
            $this->srvstr=sprintf('{%s:%d/%s', $this->getHost(), $this->getPort(), $this->getProtocol());
            if(!strcasecmp($this->getEncryption(), 'SSL'))
                $this->srvstr.='/ssl';

            // Change this line to make mail fetch work again   
            // $this->srvstr.='/novalidate-cert}';
            $this->srvstr.='/notls}';

This fix likely breaks SSL connections and should be reverted if you want to use SSL in the future, so I can't say it's a pretty fix, but it works for me and I don't want to spend much time looking into it further.

As proof of concept I made a small php script to test imap connections (i called it test.php in my users' home directory). It simply counts the nr of messages in the INBOX folder and prints it to the terminal.

<?php
$server = '{serveraddress_here:143/imap/notls}INBOX';
$imap_connection = imap_open($server, 'imap user here', 'password here');
$mailboxinfo = imap_mailboxmsginfo($imap_connection);
$messageCount = $mailboxinfo->Nmsgs;
echo $messageCount;
echo "\n";
?>

Output without "/notls" at the end of the server string
user@server:$ php test.php
PHP Warning: imap_open(): Couldn't open stream {mail.simplycode.nl:143/imap}INBOX in /home/user/test.php on line 3
PHP Warning: imap_mailboxmsginfo() expects parameter 1 to be resource, boolean given in /home/user/test.php on line 4
PHP Notice: Trying to get property 'Nmsgs' of non-object in /home/user/test.php on line 5
PHP Notice: Unknown: TLS/SSL failure for mail.simplycode.nl: SSL negotiation failed (errflg=2) in Unknown on line 0

Output with "/notls" at the end of the server string
user@server:$ php test.php
1

2 years later

Hi elgl, I made this account just to say thank you, I know this thread is 2 years old, but this has been driving me crazy for the last couple of months and your fix solved it. thank you for taking the time to update your own issue to help folks like me.

Write a Reply...