Support » Plugin: Gmail SMTP » Uncaught exception ‘InvalidArgumentException’ w/message ‘Invalid token format’

  • Hi @naa986,

    Great plugin (so far) but the emails are not sending.
    This is what error.log of our hosting says;

    [Tue Dec 12 14:50:44.039355 2017] [lsapi:error] [pid 452193:tid 140040010450688] [client 212.xx.xx.xxx:51883] [host www.mydomain.com] Backend fatal error: PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid token format' in /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php:434\nStack trace:\n#0 /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/class.phpmaileroauthgoogle.php(139): Google_Client->setAccessToken('{"error":"inval...')\n#1 /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php(475): GmailXOAuth2->getOauth64()\n#2 /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/class.phpmaileroauth.php(153): SMTP->authenticate('', '', 'XOAUTH2', '', '', Object(GmailXOAuth2))\n#3 /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmailer.php(1542): PHPMailerOAuth->smtpConnect(Array)\n#4 /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmailer.php(1337): PHPMailer->smtpS in /home/myuser/domains/mydomain.com/public_html/v2/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php on line 434\n, referer: https://www.mydomain.com/v2/wp-admin/options-general.php?page=gmail-smtp-settings&action=test-email

    this is what the plugin gives as result after trying to send a test email;

    2017-12-12 13:50:42 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
    2017-12-12 13:50:43 Connection: opened
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is ""
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP v20sm8019741edm.10 - gsmtp"
    2017-12-12 13:50:43 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP v20sm8019741edm.10 - gsmtp
    2017-12-12 13:50:43 CLIENT -> SERVER: EHLO www.mydomain.com
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is ""
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [185.xx.xx.xx]"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-SIZE 35882577"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-8BITMIME"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-STARTTLS"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-STARTTLS"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-PIPELINING"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250-CHUNKING"
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "250 SMTPUTF8"
    2017-12-12 13:50:43 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    2017-12-12 13:50:43 CLIENT -> SERVER: STARTTLS
    2017-12-12 13:50:43 SMTP -> get_lines(): $data is ""
    2017-12-12 13:50:43 SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS"
    2017-12-12 13:50:43 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
    2017-12-12 13:50:44 CLIENT -> SERVER: EHLO www.mydomain.com
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is ""
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [185.xx.xx.xx]"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-SIZE 35882577"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-8BITMIME"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-PIPELINING"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250-CHUNKING"
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "250 SMTPUTF8"
    2017-12-12 13:50:44 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [185.xx.xx.xx]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    2017-12-12 13:50:44 Auth method requested: XOAUTH2
    2017-12-12 13:50:44 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
    2017-12-12 13:50:44 CLIENT -> SERVER: QUIT
    2017-12-12 13:50:44 SMTP -> get_lines(): $data is ""
    2017-12-12 13:50:44 SMTP -> get_lines(): $str is "221 2.0.0 closing connection v20sm8019741edm.10 - gsmtp"
    2017-12-12 13:50:44 SERVER -> CLIENT: 221 2.0.0 closing connection v20sm8019741edm.10 - gsmtp
    2017-12-12 13:50:44 Connection: closed

    Server info:

    OS: Linux web01.myhost.com 2.6.32-673.26.1.lve1.4.30.el6.x86_64 #1 SMP Wed Jun 21 19:37:37 EDT 2017 x86_64
    PHP version: 5.6.32
    WordPress version: 4.9.1
    WordPress multisite: No
    openssl: Available
    allow_url_fopen: Enabled
    stream_socket_client: Available
    fsockopen: Available
    cURL: Available
    cURL Version: 7.19.7, NSS/3.27.1

    Sidenote; I’ve removed our domainname and IP from all lines.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter remi123

    (@remi123)

    Hi @naa986,

    I’ve followed the steps of ‘Fresh Authorization’ (revoked access and deleted access key) and granted access again.
    Got the same results;

    error.log

    [Wed Dec 13 09:41:09.167646 2017] [lsapi:error] [pid 104091:tid 140039989470976] [client 212.45.43.190:62093] [host www.cityspotz.nl] Backend fatal error: PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid token format' in /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php:434\nStack trace:\n#0 /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/class.phpmaileroauthgoogle.php(139): Google_Client->setAccessToken('{"error":"inval...')\n#1 /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php(475): GmailXOAuth2->getOauth64()\n#2 /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/class.phpmaileroauth.php(153): SMTP->authenticate('', '', 'XOAUTH2', '', '', Object(GmailXOAuth2))\n#3 /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmailer.php(1542): PHPMailerOAuth->smtpConnect(Array)\n#4 /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmailer.php(1337): PHPMailer->smtpS in /home/cityspotz/domains/cityspotz.nl/public_html/v2/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php on line 434\n, referer: https://www.cityspotz.nl/v2/wp-admin/options-general.php?page=gmail-smtp-settings&action=test-email

    Test Eail result:

    2017-12-13 08:41:08 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
    2017-12-13 08:41:09 Connection: opened
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is ""
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP l50sm824677eda.85 - gsmtp"
    2017-12-13 08:41:09 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP l50sm824677eda.85 - gsmtp
    2017-12-13 08:41:09 CLIENT -> SERVER: EHLO www.cityspotz.nl
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is ""
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [185.12.13.17]"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-SIZE 35882577"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-8BITMIME"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-STARTTLS"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-STARTTLS"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-PIPELINING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-CHUNKING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250 SMTPUTF8"
    2017-12-13 08:41:09 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    2017-12-13 08:41:09 CLIENT -> SERVER: STARTTLS
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is ""
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS"
    2017-12-13 08:41:09 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
    2017-12-13 08:41:09 CLIENT -> SERVER: EHLO www.cityspotz.nl
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is ""
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [185.12.13.17]"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-SIZE 35882577"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-8BITMIME"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-PIPELINING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250-CHUNKING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING"
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "250 SMTPUTF8"
    2017-12-13 08:41:09 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [185.12.13.17]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    2017-12-13 08:41:09 Auth method requested: XOAUTH2
    2017-12-13 08:41:09 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
    2017-12-13 08:41:09 CLIENT -> SERVER: QUIT
    2017-12-13 08:41:09 SMTP -> get_lines(): $data is ""
    2017-12-13 08:41:09 SMTP -> get_lines(): $str is "221 2.0.0 closing connection l50sm824677eda.85 - gsmtp"
    2017-12-13 08:41:09 SERVER -> CLIENT: 221 2.0.0 closing connection l50sm824677eda.85 - gsmtp
    2017-12-13 08:41:09 Connection: closed
    Thread Starter remi123

    (@remi123)

    After some debugging I found this error message inside $options = gmail_smtp_get_option();

    [oauth_access_token] => {"error":"invalid_grant","error_description":"Code was already redeemed."}

    Do you know how to fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Uncaught exception ‘InvalidArgumentException’ w/message ‘Invalid token format’’ is closed to new replies.