You can insert the given code in line 148 of wp_mail_smtp.php as follows:
// If we're sending via SMTP, set the host
if (get_option('mailer') == "smtp") {
// Set the SMTPSecure value, if set to none, leave this blank
$phpmailer->SMTPSecure = get_option('smtp_ssl') == 'none' ? '' : get_option('smtp_ssl');
// Set the other options
$phpmailer->Host = get_option('smtp_host');
$phpmailer->Port = get_option('smtp_port');
// https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
// https://php.net/manual/en/migration56.openssl.php
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
// If we're using smtp auth, set the username & password
if (get_option('smtp_auth') == "true") {
$phpmailer->SMTPAuth = TRUE;
$phpmailer->Username = get_option('smtp_user');
$phpmailer->Password = get_option('smtp_pass');
}
}
Just replace $mail
with $phpmailer
. Worked for me.