Title: stream_socket_enable_crypto(): SSL operation failed with code 1
Last modified: August 31, 2016

---

# stream_socket_enable_crypto(): SSL operation failed with code 1

 *  [andreuerj](https://wordpress.org/support/users/andreuerj/)
 * (@andreuerj)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/)
 * After upgrading PHP to 5.6 or 7, every attempt to send an email fail and the 
   following error message is shown:
 * Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL
   Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
   verify failed in /xpto/xpto/xpto/public_html/wp-includes/class-smtp.php on line
   343
 * [https://wordpress.org/plugins/wp-mail-smtp/](https://wordpress.org/plugins/wp-mail-smtp/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Rafa Gallego](https://wordpress.org/support/users/rafa-gt/)
 * (@rafa-gt)
 * [10 years ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-7458163)
 * Same issue here.
 * I have upgraded from PHP 5.3 to 5.6, and suddenly I get this error. Any suggestion?
 *  [bruno.carvalho](https://wordpress.org/support/users/brunocarvalho/)
 * (@brunocarvalho)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-7458201)
 * Put this code before line 149 (`$phpmailer = apply_filters('wp_mail_smtp_custom_options',
   $phpmailer);`)
 *     ```
       $phpmailer->SMTPOptions = array(
       			'ssl' => array(
       				'verify_peer' => false,
       				'verify_peer_name' => false,
       				'allow_self_signed' => true
       				)
       			);
       		}
       ```
   
 * In file wp_mail_smtp.php inside plugin folder.
 *  [enreas](https://wordpress.org/support/users/juandiegogutirrezgallardo/)
 * (@juandiegogutirrezgallardo)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-7458245)
 * Just as Bruno said, but with a minor change:
 *     ```
       $phpmailer->SMTPOptions = array(
       	'ssl' => array(
       		'verify_peer' => false,
       		'verify_peer_name' => false,
       		'allow_self_signed' => true
       	)
       );
       ```
   
 * That is, removing the closing curly bracket at the end.
 *  [Marco Almeida | Webdados](https://wordpress.org/support/users/webdados/)
 * (@webdados)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-7458264)
 * Do not edit the plugin code.
 * This should be fixed by the developer.
 *  [jagguy2](https://wordpress.org/support/users/jagguy2/)
 * (@jagguy2)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8611990)
 * yes the additions worked , well done.
 * The plugin should not be available as it is faulty without it..
 *  [Marco Almeida | Webdados](https://wordpress.org/support/users/webdados/)
 * (@webdados)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8612036)
 * Is there anybody out there?
 *  [Marco Almeida | Webdados](https://wordpress.org/support/users/webdados/)
 * (@webdados)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8612210)
 * Actually this only happens when you use a server hostname not exactly the same
   as the one the digital certificate was issued to.
 * If you try to set up an account on Outlook, Mail.app, etc… and do the same, you’ll
   have get warnings / errors.
 * Maybe this should not be seen as a bug, but as an option to either ignore the
   hostname mismatch or not.
 *  [jagguy2](https://wordpress.org/support/users/jagguy2/)
 * (@jagguy2)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8612637)
 * This is a bug and it needs to be fixed up. You cant ignore the error as no message
   will be sent.
 * “Actually this only happens when you use a server hostname not exactly the same
   as the one the digital certificate was issued to.”
 * Need some convincing of this one!
 *  [Marco Almeida | Webdados](https://wordpress.org/support/users/webdados/)
 * (@webdados)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8612674)
 * [@jagguy2](https://wordpress.org/support/users/jagguy2/)
 * I can give you a real case scenario:
 * My company dedicated server has a valid digital certificate on the WHM/cPanel
   domain: servername.ourdomain.com (example domain) so that all WHM/cPanel traffic
   is handled over https. This certificate is also used for POP/SMTP/IMAP connections.
 * On this server we host several domains (ours and clients). When someone sets 
   up an email client (like Outlook or Mail.app or any other) to connect to our 
   server via SSL, if he uses mail.hisdomain.com instead of servername.ourdomain.
   com he’ll (correctly) get an error (or at least a warning) that the SSL certificate
   is not issued to the domain he’s connecting to although it’s the same server/
   IP. It’s actually not the same domain.
 * Even cPanel instructions on how to setup an email client are clear that the hostname
   used should be the one the SSL certificate is issued to:
     Unless you don’t want
   to use SSL, and then you can use your own domain hostname:
 * So, contrarily to my initial reaction on this issue, I do think this is actually
   pretty standard: do not connect securely to a server if the SSL certificate is
   not valid for the provided hostname.
    -  This reply was modified 9 years, 5 months ago by [Marco Almeida | Webdados](https://wordpress.org/support/users/webdados/).
      Reason: Nem image for non SSL connections
 *  [kyuumeitai](https://wordpress.org/support/users/kyuumeitai/)
 * (@kyuumeitai)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8884330)
 * [@jagguy2](https://wordpress.org/support/users/jagguy2/)
 * Before replying you should see the plugin changelog and the code itself. This
   is resolved in the last update.
 * In the last version the author did add a filter, you can use it in your functions.
   php file like this:
 *     ```
       function your_smtp_options($phpmailer){
       	$phpmailer->SMTPOptions = array(
       		'ssl' => array(
       			'verify_peer' => false,
       			'verify_peer_name' => false,
       			'allow_self_signed' => true
       		)
       	);
       	return $phpmailer;
       }
   
       add_filter( 'wp_mail_smtp_custom_options', 'your_smtp_options' );
       ```
   

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘stream_socket_enable_crypto(): SSL operation failed with code 1’ is closed
to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

## Tags

 * [SSL](https://wordpress.org/support/topic-tag/ssl/)

 * 10 replies
 * 7 participants
 * Last reply from: [kyuumeitai](https://wordpress.org/support/users/kyuumeitai/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/stream_socket_enable_crypto-ssl-operation-failed-with-code-1/#post-8884330)
 * Status: not resolved