I’m having a hard time trying to figure out how to resolve this problem. When i send mail with wp_mail(), i get an authentification error but, if a try the same configuration from a blank phpmailer (outside of wordpress), it work!

Here the setup in WordPress (functions.php)

    if(!function_exists('phpmailer_smtp')){
      add_action( 'phpmailer_init', 'phpmailer_smtp' );
      function phpmailer_smtp( $phpmailer ) {

        $phpmailer->isSMTP();
        $phpmailer->Host = 'xxxx';
        $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate
        $phpmailer->Username = 'xxxx';
        $phpmailer->Password = 'xxxx';
        $phpmailer->Port = 25; 
        $phpmailer->SMTPDebug = 2;
        $phpmailer->setFrom('admin@xxxx.com','xxxx');
    }
}

Output:

2017-04-07 15:22:59 SERVER -> CLIENT: 220 ************************************************************************************************
2017-04-07 15:22:59 CLIENT -> SERVER: EHLO www.xxxx.com
2017-04-07 15:22:59 SERVER -> CLIENT: 250-SKYEX02.xxxx.montreal Hello [199.115.127.83]
                                      250-SIZE 37748736
                                      250-PIPELINING
                                      250-DSN
                                      250-ENHANCEDSTATUSCODES
                                      250-XXXXXXXA
                                      250-XXXXXXXXXXXXXB
                                      250-AUTH NTLM
                                      250-XXXXXXXXXXXXXXXXXC
                                      250-8BITMIME
                                      250-BINARYMIME
                                      250-XXXXXXXD
                                      250 XXXXE
2017-04-07 15:22:59 SMTP Error: Could not authenticate.
2017-04-07 15:22:59 CLIENT -> SERVER: QUIT
2017-04-07 15:22:59 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
2017-04-07 15:22:59 SMTP Error: Could not authenticate.

Read more here: WordPress + SMTP from Exchange Server cannont authentificate


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: