{"action":"created","issue":{"url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/677","repository_url":"https://api.github.com/repos/PHPMailer/PHPMailer","labels_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/677/labels{/name}","comments_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/677/comments","events_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/677/events","html_url":"https://github.com/PHPMailer/PHPMailer/issues/677","id":146171771,"number":677,"title":"PHPMailer gmail_xoauth.phps example from github","user":{"login":"renardrouge","id":10366395,"avatar_url":"https://avatars.githubusercontent.com/u/10366395?v=3","gravatar_id":"","url":"https://api.github.com/users/renardrouge","html_url":"https://github.com/renardrouge","followers_url":"https://api.github.com/users/renardrouge/followers","following_url":"https://api.github.com/users/renardrouge/following{/other_user}","gists_url":"https://api.github.com/users/renardrouge/gists{/gist_id}","starred_url":"https://api.github.com/users/renardrouge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renardrouge/subscriptions","organizations_url":"https://api.github.com/users/renardrouge/orgs","repos_url":"https://api.github.com/users/renardrouge/repos","events_url":"https://api.github.com/users/renardrouge/events{/privacy}","received_events_url":"https://api.github.com/users/renardrouge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":22,"created_at":"2016-04-06T02:54:54Z","updated_at":"2016-04-07T00:13:13Z","closed_at":null,"body":"I have been trying to get the gmail_xoauth.phps example running from the github site for a number of days now following these instructions.\r\n\r\nhttps://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2\r\n\r\nI have repeated the instructions faithfully and googled the error and followed the suggestions on this forum to no avail.\r\n\r\nI always end with \"SMTP ERROR: AUTH command failed: 334\".\r\n\r\n(The format presented at the google developers site is now slightly different from that shown in the instructions.)\r\n\r\nThe only difference from the instructions up to the point of failure is the absence of\r\n250-CHUNKING in the SERVER -> CLIENT response.\r\n\r\nHere is my current state.   Can anyone offer suggestions as to how I can get closer to a solution ?\r\n(confidential information replaced by xxxxx)\r\n\r\nThe following change was made to php.ini to get to this point.\r\n[cURL] curl.cainfo = C:\\xampp\\php\\cacert.pem\r\n\r\nThis code was also added to gmail_xoauth.php\r\n\r\n// LAD, 2016-04-05\t// unsecure fix for \"Warning: stream_socket_enable_crypto(): SSL operation failed with code 1\"\r\n// see https://github.com/PHPMailer/PHPMailer/issues/368\r\n\r\n$mail->SMTPOptions = array(\r\n    'ssl' => array(\r\n        'verify_peer' => false,\r\n        'verify_peer_name' => false,\r\n        'allow_self_signed' => true\r\n    )\r\n);\r\n\r\n\r\nphp version = 5.6.15\r\nPHPMailer version = 5.2.14\r\nApache version = Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.15 \r\n\r\n-----------------------------------------------------------------------\r\n\r\nredo steps at https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2\r\n\r\nhttps://console.developers.google.com/project\r\n\r\nCreate project\r\n\tproject name:\tphpmailer3\r\n\tproject id:\tphpmailer3-1273\r\n\tapp engine location:\tus-central\r\n\r\nGoogle APIs\r\n\tclick Gmail API\r\n\tclick Enable Gmail API\r\n\t\tThis API is enabled, but you can't use it in your project until you create credentials.\r\n\t\tClick \"Go to Credentials\" to do this now (strongly recommended). \r\n\r\nNow select Credentials from the left-hend menu, then click the Create new Client ID button:\r\n\t\r\nclick Create Credentials button\r\n\t\tWhich API ?\tGmail API\r\n\t\tCalling API from ?\tWeb Server\r\n\t\tWhat data ?\tUser data\r\n\t\r\nclick 'What credentials do I need ?'\r\n\t\tCalling Gmail API from a web server\r\n\t\t\r\n2 Create an OAuth 2.0 client ID \r\n\t\tname:\tphpmailer3\r\n\t\tauthorized redirect uri: https://localhost/phpmailer2/get_oauth_token.php\r\n\t\r\nclick 'Create client ID'\r\n\t\tCreated OAuth client 'phpmailer3' \r\n\t\tEmail address 'xxxxxxxxxx@gmail.com'\r\n\t\tProduct name shown to users 'PHPMailer3'\r\n\t\r\nclick 'Continue'\r\n\t\tDownload credentials\r\n\t\tClient ID\r\n\t\txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\r\n\t\t\r\n\t\tDownload this credential information in JSON format. \r\n\r\n\tclick 'Download'\r\n\t\tclient_id.json is downloaded\r\n\r\npaste the new values into get_oauth_token.php\t\t\r\n$redirectUri = 'http://localhost/phpmailer2/get_oauth_token.php';\r\n$clientId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com';\r\n$clientSecret = 'xxxxxxxxxxxxxxxxxxxxxxxx';\r\n\r\nFetch the token with get_oauth_token.php\r\n\tRefresh Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n\t\r\npaste the new values into gmail_xoauth.php and try again\r\n\r\n-----------------------------------------------------------------------------------\r\nSERVER -> CLIENT: 220 smtp.gmail.com ESMTP 31sm483745ioj.17 - gsmtp\r\nCLIENT -> SERVER: EHLO localhost\r\nSERVER -> CLIENT: 250-smtp.gmail.com at your service, [xx.xxx.xxx.xx]\r\n\t250-SIZE 35882577\r\n\t250-8BITMIME\r\n\t250-STARTTLS\r\n\t250-ENHANCEDSTATUSCODES\r\n\t250-PIPELINING\r\n\t250 SMTPUTF8\r\nCLIENT -> SERVER: STARTTLS\r\nSERVER -> CLIENT: 220 2.0.0 Ready to start TLS\r\nCLIENT -> SERVER: EHLO localhost\r\nSERVER -> CLIENT: 250-smtp.gmail.com at your service, [xx.xxx.xxx.xx]\r\n\t250-SIZE 35882577\r\n\t250-8BITMIME\r\n\t250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n\t250-ENHANCEDSTATUSCODES\r\n\t250-PIPELINING\r\n\t250 SMTPUTF8\r\nCLIENT -> SERVER: AUTH XOAUTH2 dXNlcj1sb3JuZWR1ZGxleUBnbWFpbC5jb20BYXV0aD1CZWFyZXIgeWEyOS4udkFKeDE1U1plODFQOHlQLWMwN29qMDFjM0VtT3ZFTTlUMFVHZzV6bFF0dkRUQ0poaWdIVXUydl9fQk1uOGstVDRRAQE=\r\nSERVER -> CLIENT: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==\r\nSMTP ERROR: AUTH command failed: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==\r\nSMTP Error: Could not authenticate.\r\nCLIENT -> SERVER: QUIT\r\nSERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 31sm483745ioj.17 - gsmtp\r\nSMTP ERROR: QUIT command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 31sm483745ioj.17 - gsmtp\r\nSMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting\r\nMailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting\r\n-----------------------------------------------------------------------------------\r\n"},"comment":{"url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/comments/206628252","html_url":"https://github.com/PHPMailer/PHPMailer/issues/677#issuecomment-206628252","issue_url":"https://api.github.com/repos/PHPMailer/PHPMailer/issues/677","id":206628252,"user":{"login":"renardrouge","id":10366395,"avatar_url":"https://avatars.githubusercontent.com/u/10366395?v=3","gravatar_id":"","url":"https://api.github.com/users/renardrouge","html_url":"https://github.com/renardrouge","followers_url":"https://api.github.com/users/renardrouge/followers","following_url":"https://api.github.com/users/renardrouge/following{/other_user}","gists_url":"https://api.github.com/users/renardrouge/gists{/gist_id}","starred_url":"https://api.github.com/users/renardrouge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renardrouge/subscriptions","organizations_url":"https://api.github.com/users/renardrouge/orgs","repos_url":"https://api.github.com/users/renardrouge/repos","events_url":"https://api.github.com/users/renardrouge/events{/privacy}","received_events_url":"https://api.github.com/users/renardrouge/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T00:13:13Z","updated_at":"2016-04-07T00:13:13Z","body":"Hi sherryl4george !   Well, I found I had to dig into composer syntax again.  The ReadME says to add \"phpmailer/phpmailer\": \"~5.4\" to the .json file, but that did not work.  I finally got version 5.4 to install with a \"composer update\" and the following .json\r\n\r\n{\r\n    \"require-dev\": {\r\n        \"phpmailer/phpmailer\": \"5.4.x-dev\",\r\n        \"league/oauth2-client\": \"^1.3\",\r\n        \"league/oauth2-google\": \"^1.0\"\r\n    }\r\n}\r\n\r\nI then ran gmail_xoauth again and I am stuck at\r\n\r\nFatal error: Call to undefined method PHPMailer\\PHPMailer\\PHPMailer::setOAuth() in C:\\xampp\\htdocs\\phpmailer2\\gmail_xoauth_v2.php on line 56\r\n\r\nline 56 starts with\r\n$mail->setOAuth(\r\n    new OAuth([\r\n        'provider' => $provider,\r\n        'clientId' => $clientId,\r\n        'clientSecret' => $clientSecret,\r\n        'refreshToken' => $refreshToken,\r\n        'userName' => $email\r\n    ])\r\n);\r\n\r\nSuggestions ???\r\n\r\n"}}