Tips How to use self signed certs for SSL/TLS IMAP and SMTP

Compatible XF 2.x versions
  1. 2.2
If you have an SMTP or IMAP server that has a self signed certifcate, you will need to make 2 file edits to prevent a connection failure.

src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php

paste this after
PHP:
$options = [];
src/vendor/laminas/laminas-mail/src/Protocol/Imap.php

replace this
PHP:
$this->socket = fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
With this:
PHP:
        $options = [
            'ssl' => [
                'verify_peer_name' => false,
                'verify_peer'      => false,
            ]
        ];
        $context = stream_context_create($options);
        $this->socket = stream_socket_client("{$host}:{$port}", $errno, $errstr, self::TIMEOUT_CONNECTION, STREAM_CLIENT_CONNECT, $context);
 

Similar threads

October 2024

Total amount
$160.50
Goal
$400.00
Donation ends:

Staff online

Forum statistics

Threads
10,651
Messages
28,709
Members
48,021
Latest member
Saurabh
Top