Search code examples
phpemailweb-applicationsgmailphpmailer

Error while trying to get access to google.com for my local web application


I hope someone of you can give me some helpful instructions about this problem! I'm getting mad! The fact is this: I would like to send emails by my local web application using Google SMTP. I created a .json file in the root folder of my application like this:

{
"require": {
    "phpmailer/phpmailer": "^5.2",
    "league/oauth2-client": "^1.0"
}}

In order to download and install by compiler the PHPMailer and the oauth2client that is needed. Then I created a new project in the google developer console and I configured it: I enabled gmail API, obtained the correct credentials (ID and SECRET) and set the authorized direct URI like this:

http://localhost/folder1/vendor/phpmailer/phpmailer/get_oauth_token.php

Now I edited the get_oauth_token.php with the obtained credentials, but then when I try to insert the previous URI in the browser to get the permissions an errror is occurring:

Fatal error: Class 'League\OAuth2\Client\Provider\Google' not found in C:\xampp\htdocs\folder1\vendor\phpmailer\phpmailer\get_oauth_token.php on line 28

And i can't go on.. I tried to send and email with a main php script but obviously i can't get access and my request is refused by the server. Any suggestions? Thanks and have a nice day!


Solution

  • had the exact same problem. what i did was to install:

    composer require league/oauth2-google
    

    and the problem dissapear

    ;)