Magento – HELP! Magento 2 SMTP setup Could not open socket: stream_socket_client(): Peer certificate not match

magento2smtp

I use Mageplaza SMTP extension to setup the SMTP. When testing the connection, it popped up the follow error. I have already tried some solution online, like trying to modify abstract.php file. There is also an answer saying it maybe caused by shared host, since I am also hosting the website in shared host. But I contacted bluehost, they said my MX is pointing to Google. They won't block anything. Any ideas on this issue?
php version: 7.1
Magento 2 version: 2.3.2
enter image description here

Best Answer

Reference Link

You need to try this.

open this file : vendor\magento\zendframework1\library\Zend\Mail\Protocol\Abstract.php

arround line no 267.

$this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);

comment above line and add this code below that line.

$stream_context = stream_context_create(array(
 'ssl' => array(
  'verify_peer'       => false,
  'verify_peer_name'  => false,
  'allow_self_signed' => true
  )
 ));
$this->_socket = stream_socket_client(
  $remote, 
  $errorNum, 
  $errorStr, 
  self::TIMEOUT_CONNECTION, 
  STREAM_CLIENT_CONNECT, 
  $stream_context 
 );
Related Topic