I have now seen this error by a client of me. He had the same error by using a local ip address. It seems fsockopen can't connect to the server using ssl, if the certificate can't verified.
To fix this error, the connection should be made with stream_socket_client().

KevinTheJedi Can we made fixes in the folder ./include/laminas-mail/src/ ? I think this folder don't belongs to the laminas-mail framework. Is this right?
I would change it to stream_socket_client() and create a pull request, if we can made changes in this folder...

In this folder, some files have errors, too. So I would fix these errors too...

    jens_E

    You’d have to submit these changes to laminas-mail directly. Anything in include/laminas-mail is 3rd party files.

    Cheers.

      jens_E

      Now that you mentioned it, this may be our issue as well.

      We are also trying to connect to our server with a local IP and we can't get the host certified since the IP address isn't visible on the web nor do we have a dedicated public domain to assign to it.

      Okay, I will write a solution, who needs to solve this error now. This solution will only nessesary, if the connection uses SSL...
      For POP3 connections:
      Go to file /include/laminas-mail/src/Protocol/Pop3.php to Line 96 and replace
      $this->socket = fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
      with
      $context = stream_context_create([
      'ssl' => [
      'verify_peer' => false,
      'verify_peer_name' => false
      ]
      ]);
      $this->socket = stream_socket_client($host.':'.$port, $errno, $errstr, self::TIMEOUT_CONNECTION, STREAM_CLIENT_CONNECT, $context);

      For IMAP4 connections, you find the same code in:
      /include/laminas-mail/src/Protocol/Imap.php in Line 91
      There you find the same code to replace...

      I hope this changes are useful for someone.
      It's not an official solution, but it works.

      Unfortunately this does not work for us. After replacing Line 91 in Imap.php we can save/activate E-Mail without error but than nothing happens. Mails arent fetched... :/

      A quick solution would be great....

      I wanted to make a request to laminas-mail directly, but I saw, the latest version of laminas-mail solves this error.
      laminas-mail 2.18.0 connect to mail servers with stream_socket_client(), not using fsockopen(). So there is a solution to disable certificate validation.
      KevinTheJedi
      I made a pull request to update laminas-mail to 2.18.0 and disabled the validation. Please see at:
      https://github.com/osTicket/osTicket/pull/6312
      There is already a pull request to update laminas-mail, but I removed all development dependencies.
      So laminas-mail includes less than 500 files by using 3,5 MB...
      laminas-mail should not have more files as osTicket itself.
      Please merge this request for the next release.

        KevinTheJedi
        Hi,

        We are confirming that the above change proposed by jens_E is also working for us.

        Realized that this thread is apparently covering two separate issues. :]

        Thank you!

          Hi sushpep

          are you using IMAP? What did you canged? Line 91 in Imap.php?

          We've tried but does not work for us.

          Without change we get:

          And if we change as jens_E described the is no error shown but mails aren't fetched.

          Regards!

            And your cronJob is enabled?
            You can set your log level to debug in Settings->System.
            Then you can see, if the cron runs in your system log. There should be an entry for it...

              jens_E

              Hmmmm....
              Looks like i run into another issue:
              If i start the job manually i get:

              ###############
              /home/ticketing/public_html/api/cron.php
              PHP Fatal error: Abstract function osTicket\Mail\MailBoxProtocolTrait::oauth2Auth() cannot be declared private in /home/ticketing/public_html/include/class.mail.php on line 238
              ###############

              a month later

              @jens_E @KevinTheJedi
              I've updated to 1.17.1
              Same error. Edited Imap.php again. No more error but mails aren't fetched!
              So something has changed with 1.17.1 but not for good. :/

              For now i revert to last snapshot to get it working again. But a final solution would be great.

              8 days later

              Hi,
              short update. With 1.17.2 the problem still persists:

              Manual edit of Imap.php fixed it again.

              Regards!
              Gero

              Write a Reply...