Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WP Mail SMTP: when using SMTP mailer - disable SSL verify on PHP 5.6+
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
return $phpmailer;
} );
@myselfhimself

This comment has been minimized.

Copy link

@myselfhimself myselfhimself commented Jan 30, 2018

Thank you for pasting! To be used with this plugin: https://wordpress.org/plugins/wp-mail-smtp/

@harisrozak

This comment has been minimized.

Copy link

@harisrozak harisrozak commented Jan 9, 2020

Thank you!, I was stuck on "error sending email" before applying this code

@SimonFricker

This comment has been minimized.

Copy link

@SimonFricker SimonFricker commented Apr 17, 2020

Not working anymore

@rklabal

This comment has been minimized.

Copy link

@rklabal rklabal commented May 22, 2020

Still working, thanks a lot.

@Whateverinc

This comment has been minimized.

Copy link

@Whateverinc Whateverinc commented Jun 17, 2020

I don't think this is secure.

@slaFFik

This comment has been minimized.

Copy link
Owner Author

@slaFFik slaFFik commented Jun 17, 2020

@Whateverinc Its definitely not secure. And users should fix there server setup to use a proper certificate.

@harisrozak

This comment has been minimized.

Copy link

@harisrozak harisrozak commented Jun 17, 2020

@slaFFik in my case, the client has been used this "unsecured" email server for a long time, and they don't even mind that issue as long as it works, and as a new developer for a new app, I must adapt

@ClaudiaFat

This comment has been minimized.

Copy link

@ClaudiaFat ClaudiaFat commented Sep 14, 2020

hola yo tambien tengo problemas, no envia ni el correo de prueba (y ojo que estoy haciendo la prueba con un correo de gmail), me sale el sgte mensaje

No se pudo conectar con el host SMTP.

Esto significa que tu servidor web no pudo conectarse a smtp.gmail.com.

Normalmente, este error se devuelve por uno de los siguientes motivos:

-Los ajustes SMTP son incorrectos (puerto incorrecto, ajustes de seguridad, host incorrecto).
-Su servidor web está bloqueando la conexión.
-Tu host SMTP está rechazando la conexión.

si me pueden ayudar porfavor

@DevKishan

This comment has been minimized.

Copy link

@DevKishan DevKishan commented Sep 26, 2020

Thank you very much. Resolved the SSL related error and was able to send emails on my localhost setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.