问题
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!
回答1:
had the exact same problem. what i did was to install:
composer require league/oauth2-google
and the problem dissapear
;)
回答2:
The PHPMailer composer.json
can't require the league OAuth2 packages by default for 2 reasons:
- They will break on PHP versions < 5.4 and the rest of PHPMailer supports back to 5.0
- Not everyone needs them.
For these reasons they are in the 'suggests' section of the composer.json, so you will need to manually require them for your project. Do that, and the autoloader will be able to find them.
来源:https://stackoverflow.com/questions/33013008/error-while-trying-to-get-access-to-google-com-for-my-local-web-application