Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

consigliere's avatar

SMTP Mail

I get this error:

stream_socket_enable_crypto(): Peer certificate CN=`*.swbroadband.co.uk' did not match expected CN=`
0 likes
2 replies
bobbybouwmann's avatar

This is due to the new verify-by-default policy in PHP 5.6. It's not set in php.ini; it's an option you can provide to fopen wrappers or stream contexts. Have a look at the options here, especially verify_peer. http://php.net/manual/en/context.ssl.php

PHPMailer allows you to set these params during the smtpConnect() method, but there is no option to pass options into the smtpSend() method, so you will need to subclass PHPMailer to get at that.

This might be an alternative: http://www.docnet.nu/tech-portal/2014/06/26/ssl-and-php-streams-part-1-you-are-doing-it-wrongtm/C0

1 like
itsazzad's avatar

Try unsetting encryption by removing 'tls' in \config/mail.php if you are using Non-SSL Settings

'encryption' => env('MAIL_ENCRYPTION', ''),

5 likes

Please or to participate in this conversation.