stream_socket_enable_crypto(): Peer certificate

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

.env configuration below

MAIL_DRIVER=smtp
MAIL_HOST=mail.privateemail.com
MAIL_PORT=587
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ad7dbd3d6c5cfc9dfc8d4dbd7dfa7f9f5f4eefbf9eedaf7e3def5f7fbf3f4d4fbf7ffb4f9f5f7">[email protected]</a>
MAIL_PASSWORD=myPrivateEmailPassword
MAIL_ENCRYPTION=tls
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="db969a9297849d899496849a9f9f899e8888e6b8b4b5afbab8af9bb6a29fb4b6bab2b595bab6bef5b8b4b6">[email protected]</a>
MAIL_FROM_NAME=MyCustomName

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=`111-11-11-227.cprapid.com' did not match expected CN=`mail.privateemail.com'"}

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

Laravel 5.8

Answers:

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 mail.privateemail.com, but you are actually connecting to a server called 111-11-11-227.cprapid.com. 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 stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x