I have decided to connect wp_mail to my "Gandi" authenticated SMTP server to improves the reliability of wp_mail, and avoids many potential problems (with gmail ...)
When I want to get a new password with the WP reset password form and click on the button "Get a new password", wordPress returns the error message "The e-mail could not be sent..."
If I comment my //add_action( 'phpmailer_init' ...) The "Get a new password" form works again. I tried this with twentysixteen and no plugins activated.
Do someone have an idea why ?
This is my code:
add_action( 'phpmailer_init', array( &$this, 'prefix_send_smtp_email' ) , 10 );
public function prefix_send_smtp_email( PHPMailer $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "mail.gandi.net";
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = true;
// SMTP port number - likely to be 25, 465 or 587
$phpmailer->Port = "587";
// Username to use for SMTP authentication
$phpmailer->Username = "[email protected]";
// Password to use for SMTP authentication
$phpmailer->Password = "xxxxxxxx";
// Encryption system to use - ssl or tls
$phpmailer->SMTPSecure = "tls";
$phpmailer->From = "[email protected]";
$phpmailer->FromName = "Jhon Do";
}
Thanks for your help.