stream_socket_enable_crypto(): Peer certificate

I am trying to connect private email with my Laravel project.

.env configuration below

<a href="" class="__cf_email__" data-cfemail="9ad7dbd3d6c5cfc9dfc8d4dbd7dfa7f9f5f4eefbf9eedaf7e3def5f7fbf3f4d4fbf7ffb4f9f5f7">[email protected]</a>
<a href="" class="__cf_email__" data-cfemail="db969a9297849d899496849a9f9f899e8888e6b8b4b5afbab8af9bb6a29fb4b6bab2b595bab6bef5b8b4b6">[email protected]</a>

After this , I run this three command,

php artisan config:clear
php artisan config:cache
php artisan queue:restart

I have too many EmailJob files to send emails. That’s why I used the last command.

What I am getting the error?

{"status":500,"data":"stream_socket_enable_crypto(): Peer certificate CN=`' did not match expected CN=`'"}

Note: 111-11-11-227 is the fake number I gave here. Because I need to keep it private.

Laravel 5.8


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You’re getting the error because you are asking it to connect to a server called, but you are actually connecting to a server called TLS is specifically designed to reject connections when certificate names don’t match, protecting you from servers that are pretending to be something they are not.

There are several likely explanations for this.

  1. You have the wrong name for the mail server, and you’re being redirected to the right name, but it results in a name mismatch
  2. Your server name is correct, but your hosting provider is redirecting traffic to their own mail server as a spambot prevention tactic
  3. Some bad actor is intercepting your traffic and redirecting it to their own mail server (in which case, TLS is doing its job) in the hope of tricking you into revealing credentials

If it’s 1, simply change your config to use at the correct server. If its 2, perhaps point directly at your hosting provider’s mail server – their docs should tell you what to do. If it’s 3, count yourself lucky that we have TLS to protect our traffic and report it to your provider!

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x