Resource icon

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

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 = [];
PHP:
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
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)
Author
shimmer
Views
488
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from shimmer

Top