• Hello,

    I encountered the following error when I first installed the plugin and tried sending a test email:

    Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
    Connection: opened
    SMTP -> get_lines(): $data is ""
    SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP b14sm20510548pfh.114 - gsmtp"
    SERVER -> CLIENT: 220 smtp.gmail.com ESMTP b14sm20510548pfh.114 - gsmtp
    CLIENT -> SERVER: EHLO www.<website name removed>
    SMTP -> get_lines(): $data is ""
    SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [49.128.60.124]"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]"
    SMTP -> get_lines(): $str is "250-SIZE 35882577"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577"
    SMTP -> get_lines(): $str is "250-8BITMIME"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME"
    SMTP -> get_lines(): $str is "250-STARTTLS"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-STARTTLS"
    SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES"
    SMTP -> get_lines(): $str is "250-PIPELINING"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING"
    SMTP -> get_lines(): $str is "250-CHUNKING"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
    SMTP -> get_lines(): $str is "250 SMTPUTF8"
    SERVER -> CLIENT: 250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    CLIENT -> SERVER: STARTTLS
    SMTP -> get_lines(): $data is ""
    SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS"
    SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
    CLIENT -> SERVER: EHLO www.<website name removed>
    SMTP -> get_lines(): $data is ""
    SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [49.128.60.124]"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]"
    SMTP -> get_lines(): $str is "250-SIZE 35882577"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577"
    SMTP -> get_lines(): $str is "250-8BITMIME"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME"
    SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES"
    SMTP -> get_lines(): $str is "250-PIPELINING"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING"
    SMTP -> get_lines(): $str is "250-CHUNKING"
    SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
    SMTP -> get_lines(): $str is "250 SMTPUTF8"
    SERVER -> CLIENT: 250-smtp.gmail.com at your service, [49.128.60.124]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    Auth method requested: XOAUTH2
    Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
    SMTP Error: Could not authenticate.
    CLIENT -> SERVER: QUIT
    SMTP -> get_lines(): $data is ""
    SMTP -> get_lines(): $str is "221 2.0.0 closing connection b14sm20510548pfh.114 - gsmtp"
    SERVER -> CLIENT: 221 2.0.0 closing connection b14sm20510548pfh.114 - gsmtp
    Connection: closed
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

    TL;DR To work-around this I copied the PHPMailer files in the plugin directory (/wp-content/plugins/gmail-smtp/PHPMailer) to replace their counterparts in the WordPress Core (/wp-includes) directory. For example, copy “class.smtp.php” from the plugin’s PHPMailer directory to replace “class-smtp.php” (note the change of ‘.’ to ‘-‘) in /wp-includes, and “class.phpmailer.php” to replace “class-phpmailer.php”. However, this is not ideal as /wp-includes can be changed by WordPress Core updates.

    After some troubleshooting, the problem seems to be that the WordPress core (wp-includes) already contains PHPMailer files (eg. class-smtp.php and class-phpmailer.php) that have internal class name conflicts with the modified PHPMailer used by Gmail SMTP. This is not an issue if Gmail SMTP is the only plugin using PHPMailer, since in that case the WP-Core PHPMailer will never be loaded. However, because I have another plugin that uses the WP-Core PHPMailer, the WP-Core PHPMailer classes are loaded into PHP runtime first by that plugin. Subsequently (I think) when Gmail SMTP is loaded, instead of loading the classes in its modified PHPMailer files, it juse uses the WordPress Core classes of the same names which were already loaded by the other plugin earlier. As a result Gmail SMTP will end up using the WP Core PHPMailer instead of its own modified version, which obviously doesn’t have the added support needed by Gmail SMTP (eg. XOAuth2).

    @naa986, I’m no PHP expert, but for a longer-term fix, perhaps you could use a separate PHP namespace for your modified PHPMailer to distinguish it from WP-Core PHPMailer?

The topic ‘Authentication error (plugin conflict with WP Core PHPMailer)’ is closed to new replies.