<?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; | |
} ); |
where do i input this code or file location?
where do i input this code or file location?
You can put any filter or action codes (hooks), including this code on the functions.php file located on your theme. And its recommended to use a child theme to avoid file replacement on theme updating process. About child theme: https://developer.wordpress.org/themes/advanced-topics/child-themes/
Thanks works like a charm!
Thank you, it works!
I was having SMTP failure because my corporate SMTP server uses a self-signed certificate.
My first attempt was to edit WordPress core file /wp-includes/PHPMailer/PHPMailer.php
with following class attribute values:
public $SMTPOptions = [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ] ];
Although above solution worked, it triggered another issue: the plugin Wordfence complained "WordPress core file modified", which made sense to protect the WordPress core from being polluted.
So I kept search for better solution when I found this thread. I just added the codes into /wp-content/themes/{my-theme-name}/functions.php
, and my WP Mail SMTP reported Email Test successfully.
Thank you, it works! (using Wordpress 6.0 and WP Mail SMTP Version 3.2.1)
Thank you very much. Resolved the SSL related error and was able to send emails on my localhost setup.