Tag Archives: stream_socket_client

Can’t send an email on cakephp3 using Gmail? Here is the fix!

Do you see:

error- stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed stream_socket_client(): Failed to enable crypto stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error)

error when you set email transport to gmail? Your settings might look like this:

'EmailTransport' => [
..........
'gmail' => [
'className' => 'Smtp',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'xxx@xxxxx.com',
'password' => 'xxxxx',
]
]

Ok. Here is the explaination for this in this thread :

PHP 5.6 verifies SSL certificates by default, and if your cert doesn’t match, it will fail with this error. The correct solution is to fix your SSL config

Solution:

Thanks to the efforts of jagguy at this forum

All you have to do is, to add ssl configuration to the transport settings (in bold), as follows:

'EmailTransport' => [
..........
'gmail' => [
'className' => 'Smtp',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'xxx@xxxxx.com',
'password' => 'xxxxx',
'context' => [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]

]
]