Certificate error when sending an email

Asked

Viewed 1,024 times

0

Hello, yesterday when sending an email by my site and my client created by wordpress, I came across an error sending the email:

Warning:  stream_socket_enable_crypto(): Peer certificate CN=`*.locaweb.com.br' did not match expected CN=`smtp.toldosmaranata.com.br' in /home/storage/2/f3/41/toldosmaranata/public_html/wp-includes/class-smtp.php on line 367

I did some research but could not identify how to solve this problem that is in the class of smtp in line 367 that I will insert here also to facilitate:

365        if (!stream_socket_enable_crypto(
366            $this->smtp_conn,
367            true,
368            $crypto_method
369        )) {
370            return false;
371        }
372        return true;
373    }

I thank you from the outset who make available to help, grateful!

  • 1

    Is it the same issue as that link? http://stackoverflow.com/questions/30371910/phpmailer-generates-php-warning-stream-socket-enable-crypto-peer-certificate

  • Checking what reported until I could understand about the code made available to put inside the file class-smtp.. but I don’t know where I can put it in there. Can you tell me?

  • 2

    Actually it is not in the file class.smtp.php, but rather where you instantiate the class Phpmailer, example: $mail = new phpmailer(); $mail->Smtpoptions = array( ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) );

  • Right but in this case, I use the plugin contact form 7 wordpress. The error is coming from the class-smtp.php file and I don’t prompt the phpmailer class elsewhere.. what I would have to do?

  • 2

    Please backup the class.phpmailer.php file, and then change on line 275 public $SMTPOptions = array() for public $SMTPOptions = array('ssl'=>
 array('verify_peer'=>false, 
 'verify_peer_name' => false, 
 'allow_self_signed' => true ) 
 );

  • OPA! Sensational, the error has been corrected and the email is being sent! thank you very much Everson.

  • While the @Everson solution works, keep in mind that doing this will turn off the checking of cerificates which is generally totally unsafe.

Show 2 more comments

1 answer

1

In the class.phpmailer.php file on line 275 change from:

public $SMTPOptions = array();

for public

$SMTPOptions = array('ssl'=> array('verify_peer'=>false,
                                   'verify_peer_name' => false, 
                                   'allow_self_signed' => true ) );

This will disable the verification of the ssl certificate. Only do this if you are sure that the server on which you are sending your emails is safe.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.