Rearrangements for new XOAUTH approach, see #675
This commit is contained in:
parent
94c7cf4d9e
commit
3a41f91fe2
|
|
@ -60,8 +60,7 @@ If you don't speak git or just want a tarball, click the 'zip' button on the rig
|
|||
|
||||
### Minimal installation
|
||||
|
||||
While installing the entire package manually or with composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using Google XOAUTH2 you will need `src/PHPMailerOAuth.php` and `src/OAuthProvider/Google.php` classes, as well as the composer dependencies. Really, it's much easier to use composer!
|
||||
While installing the entire package manually or with composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using Google XOAUTH2 you will need [src/PHPMailerOAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailerOAuth.php) and [src/OAuthProvider/Google.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuthProvider/Google.php) classes, as well as the composer dependencies. Really, it's much easier to use composer!
|
||||
While installing the entire package manually or with composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the composer dependencies for the services you wish to authenticate with. Really, it's much easier to use composer!
|
||||
|
||||
## A Simple Example
|
||||
|
||||
|
|
|
|||
|
|
@ -3482,12 +3482,12 @@
|
|||
"version": "1.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zetacomponents/Base.git",
|
||||
"url": "https://github.com/zetacomponents/OAuth.git",
|
||||
"reference": "f20df24e8de3e48b6b69b2503f917e457281e687"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zetacomponents/Base/zipball/f20df24e8de3e48b6b69b2503f917e457281e687",
|
||||
"url": "https://api.github.com/repos/zetacomponents/OAuth/zipball/f20df24e8de3e48b6b69b2503f917e457281e687",
|
||||
"reference": "f20df24e8de3e48b6b69b2503f917e457281e687",
|
||||
"shasum": ""
|
||||
},
|
||||
|
|
@ -3536,7 +3536,7 @@
|
|||
"name": "Alexandru Stanoi"
|
||||
}
|
||||
],
|
||||
"description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.",
|
||||
"description": "The OAuth package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.",
|
||||
"homepage": "https://github.com/zetacomponents",
|
||||
"time": "2014-09-19 03:28:34"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ if (!isset($provider)) {
|
|||
]);
|
||||
}
|
||||
|
||||
$mail->setOAuth(new OAuthProvider\Base(
|
||||
$mail->setOAuth(new OAuth(
|
||||
[
|
||||
'provdier' => $provider,
|
||||
'provider' => $provider,
|
||||
'clientId' => $clientId,
|
||||
'clientSecret' => $clientSecret,
|
||||
'refreshToken' => $refreshToken,
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This example shows settings to use when sending via Google's Gmail servers using XOAUTH2.
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
$mail = new PHPMailer;
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = 2;
|
||||
$mail->Host = 'smtp.gmail.com';
|
||||
$mail->Port = 587;
|
||||
$mail->SMTPSecure = 'tls';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Subject = 'PHPMailer GMail SMTP test';
|
||||
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
|
||||
$mail->setFrom('sender@gmail.com', 'Test');
|
||||
$mail->addAddress('receiver@hotmail.com', 'Test');
|
||||
|
||||
//send the message, check for errors
|
||||
|
||||
if (!$mail->send()) {
|
||||
echo "Mailer Error: " . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo "Message sent!";
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This example shows settings to use when sending via Outlook/Microsoft Live servers using XOAUTH2.
|
||||
*/
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Load dependencies from composer
|
||||
//If this causes an error, run 'composer install'
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new Microsoft-specific PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = 2;
|
||||
$mail->Host = 'smtp-mail.outlook.com';
|
||||
$mail->Port = 587;
|
||||
$mail->SMTPSecure = 'tls';
|
||||
$mail->SMTPAuth = true;
|
||||
|
||||
//Set AuthType
|
||||
$mail->AuthType = 'XOAUTH2';
|
||||
|
||||
//User Email to use for SMTP authentication - Who authorised to access Outlook mail
|
||||
$mail->oauthUserEmail = "sender@hotmail.com";
|
||||
|
||||
//Obtained From https://account.live.com/developers/applications/index
|
||||
$mail->oauthClientId = "{YOUR_CLIENT_ID}";
|
||||
|
||||
//Obtained From https://account.live.com/developers/applications/index
|
||||
$mail->oauthClientSecret = "{YOUR_CLIENT_SECRET}";
|
||||
|
||||
//Obtained By running get_oauth_token.php
|
||||
$mail->oauthRefreshToken = "{OAUTH_REFRESH_TOKEN}";
|
||||
|
||||
$mail->setFrom('sender@hotmail.com', 'Test');
|
||||
$mail->addAddress('receiver@gmail.com', 'Test');
|
||||
$mail->Subject = 'PHPMailer hotmail XOAUTH2 SMTP test';
|
||||
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
|
||||
if (!$mail->send()) {
|
||||
echo "Mailer Error: " . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo "Message sent!";
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This example shows settings to use when sending via Yahoo servers using XOAUTH2.
|
||||
*/
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
//Load dependencies from composer
|
||||
//If this causes an error, run 'composer install'
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new Yahoo-specific PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPDebug = 2;
|
||||
$mail->Host = 'smtp.mail.yahoo.com';
|
||||
$mail->Port = 587;
|
||||
$mail->SMTPSecure = 'tls';
|
||||
$mail->SMTPAuth = true;
|
||||
|
||||
//Set AuthType
|
||||
$mail->AuthType = 'XOAUTH2';
|
||||
|
||||
//User Email to use for SMTP authentication - Who authorised to send Yahoo mail
|
||||
$mail->oauthUserEmail = 'sender@yahoo.com';
|
||||
|
||||
//Obtained From https://developer.yahoo.com/apps/
|
||||
$mail->oauthClientId = '{YAHOO_CLIENT_ID}';
|
||||
|
||||
//Obtained From https://developer.yahoo.com/apps/
|
||||
$mail->oauthClientSecret = '{CLIENT_SECRET}'';
|
||||
|
||||
// eg: http://localhost/phpmail/get_oauth_token.php
|
||||
$mail->oauthRefreshToken = '{REFRESH_TOKEN}';
|
||||
|
||||
$mail->setFrom('sender@yahoo.com', 'test');
|
||||
$mail->addAddress('receiver@gmail.com', 'test');
|
||||
$mail->Subject = 'PHPMailer Yahoo XOAUTH2 SMTP test';
|
||||
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
|
@ -30,85 +30,90 @@
|
|||
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
// Give alias to the League Provider Classes that may be used
|
||||
// Aliases for League Provider Classes that may be used
|
||||
use League\OAuth2\Client\Provider\Google as Google;
|
||||
use Stevenmaguire\OAuth2\Client\Provider\Microsoft as Microsoft;
|
||||
use Hayageek\OAuth2\Client\Provider\Yahoo as Yahoo;
|
||||
|
||||
if (!isset($_GET['code']) && !isset($_GET['provider'])) {
|
||||
?>
|
||||
<html>
|
||||
<body>Select Provider:<br/>
|
||||
<a href='?provider=Google'>Google</a><br/>
|
||||
<a href='?provider=Yahoo'>Yahoo</a><br/>
|
||||
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br/>
|
||||
</body>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<body>Select Provider:<br/>
|
||||
<a href='?provider=Google'>Google</a><br/>
|
||||
<a href='?provider=Yahoo'>Yahoo</a><br/>
|
||||
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br/>
|
||||
</body>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
session_start();
|
||||
session_start();
|
||||
|
||||
$providerName = '';
|
||||
$providerName = '';
|
||||
|
||||
if (array_key_exists('provider', $_GET)) {
|
||||
$providerName = $_GET['provider'];
|
||||
$_SESSION['provider'] = $providerName;
|
||||
} elseif (array_key_exists('provider', $_SESSION)) {
|
||||
$providerName = $_SESSION['provider'];
|
||||
}
|
||||
if (!in_array($providerName, ['Google', 'Microsoft', 'Yahoo'])) {
|
||||
exit("Only Google, Microsoft and Yahoo OAuth2 providers are currently supported.");
|
||||
}
|
||||
|
||||
//These details obtained are by setting up app in Google developer console.
|
||||
// Changed the hardcode to variables above, so even newbies can use it easily.
|
||||
$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
|
||||
$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';
|
||||
if (array_key_exists('provider', $_GET)) {
|
||||
$providerName = $_GET['provider'];
|
||||
$_SESSION['provider'] = $providerName;
|
||||
} elseif (array_key_exists('provider', $_SESSION)) {
|
||||
$providerName = $_SESSION['provider'];
|
||||
}
|
||||
if (!in_array($providerName, ['Google', 'Microsoft', 'Yahoo'])) {
|
||||
exit("Only Google, Microsoft and Yahoo OAuth2 providers are currently supported.");
|
||||
}
|
||||
|
||||
//If this automatic URL doesn't work, set it yourself manually
|
||||
$redirectUri = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
||||
//$redirectUri = 'http://localhost/PHPMailer/redirect';
|
||||
//These details obtained are by setting up app in Google developer console.
|
||||
// Changed the hardcode to variables above, so even newbies can use it easily.
|
||||
$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
|
||||
$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';
|
||||
|
||||
$provider = new Google(
|
||||
[
|
||||
//If this automatic URL doesn't work, set it yourself manually
|
||||
$redirectUri = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
||||
//$redirectUri = 'http://localhost/PHPMailer/redirect';
|
||||
|
||||
$provider = new Google(
|
||||
[
|
||||
'clientId' => $clientId,
|
||||
'clientSecret' => $clientSecret,
|
||||
'redirectUri' => $redirectUri,
|
||||
'accessType' => 'offline']
|
||||
);
|
||||
'accessType' => 'offline'
|
||||
]
|
||||
);
|
||||
|
||||
// Define scopes as a array here.
|
||||
$options = ['scope' => [
|
||||
'https://mail.google.com/'
|
||||
]];
|
||||
// Define scopes as a array here.
|
||||
$options = [
|
||||
'scope' => [
|
||||
'https://mail.google.com/'
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
if (!isset($_GET['code'])) {
|
||||
if (!isset($_GET['code'])) {
|
||||
|
||||
// If we don't have an authorization code then get one
|
||||
$authUrl = $provider->getAuthorizationUrl($options);
|
||||
// If we don't have an authorization code then get one
|
||||
$authUrl = $provider->getAuthorizationUrl($options);
|
||||
|
||||
$_SESSION['oauth2state'] = $provider->getState();
|
||||
$_SESSION['oauth2state'] = $provider->getState();
|
||||
|
||||
header('Location: ' . $authUrl);
|
||||
exit;
|
||||
header('Location: ' . $authUrl);
|
||||
exit;
|
||||
// Check given state against previously stored one to mitigate CSRF attack
|
||||
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
|
||||
unset($_SESSION['oauth2state']);
|
||||
unset($_SESSION['provider']);
|
||||
exit('Invalid state');
|
||||
} else {
|
||||
unset($_SESSION['provider']);
|
||||
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
|
||||
unset($_SESSION['oauth2state']);
|
||||
unset($_SESSION['provider']);
|
||||
exit('Invalid state');
|
||||
} else {
|
||||
unset($_SESSION['provider']);
|
||||
|
||||
// Try to get an access token (using the authorization code grant)
|
||||
$token = $provider->getAccessToken('authorization_code', array(
|
||||
// Try to get an access token (using the authorization code grant)
|
||||
$token = $provider->getAccessToken(
|
||||
'authorization_code',
|
||||
array(
|
||||
'code' => $_GET['code']
|
||||
));
|
||||
// Use this to interact with an API on the users behalf
|
||||
// Use this to get a new access token if the old one expires
|
||||
echo 'Refresh Token: ' . $token->getRefreshToken();
|
||||
}
|
||||
?>
|
||||
)
|
||||
);
|
||||
// Use this to interact with an API on the users behalf
|
||||
// Use this to get a new access token if the old one expires
|
||||
echo 'Refresh Token: ' . $token->getRefreshToken();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer\OAuthProvider;
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
class Base {
|
||||
class OAuth {
|
||||
|
||||
/**
|
||||
* @var League\OAuth2\Client\Provider\AbstractProvider
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2015 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer\OAuthProvider;
|
||||
|
||||
use League\OAuth2\Client\Provider\Google as LeagueGoogle;
|
||||
|
||||
/**
|
||||
* Wrapper for League Google OAuth2 provider.
|
||||
* @package PHPMailer
|
||||
* @author @sherryl4george
|
||||
* @author Marcus Bointon (@Synchro) <phpmailer@synchromedia.co.uk>
|
||||
* @link https://github.com/thephpleague/oauth2-client
|
||||
*/
|
||||
class Google extends Base
|
||||
{
|
||||
/**
|
||||
* Return the OAuth provider implementation for this adaptor.
|
||||
* @return League\OAuth2\Client\Provider\AbstractProvider
|
||||
*/
|
||||
public function getProvider()
|
||||
{
|
||||
if (is_null($this->provider)) {
|
||||
$this->provider = new LeagueGoogle([
|
||||
'clientId' => $this->oauthClientId,
|
||||
'clientSecret' => $this->oauthClientSecret
|
||||
]);
|
||||
}
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
'scope' => ['https://mail.google.com/'],
|
||||
'approval_prompt' => 'force'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2015 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer\OAuthProvider;
|
||||
|
||||
use Stevenmaguire\OAuth2\Client\Provider\Microsoft as StevenmaguireMicrosoft;
|
||||
|
||||
/**
|
||||
* Wrapper for League Microsoft OAuth2 provider.
|
||||
* @package PHPMailer
|
||||
* @author @hayageek
|
||||
* @author Ravishanker Kusuma (hayageek@gmail.com)
|
||||
* @link https://github.com/hayageek
|
||||
*/
|
||||
|
||||
class Microsoft extends Base
|
||||
{
|
||||
public function getProvider()
|
||||
{
|
||||
if (is_null($this->provider)) {
|
||||
$this->provider = new StevenmaguireMicrosoft([
|
||||
'clientId' => $this->oauthClientId,
|
||||
'clientSecret' => $this->oauthClientSecret
|
||||
]);
|
||||
}
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
'scope' => [
|
||||
'wl.imap',
|
||||
'wl.offline_access'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2015 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer\OAuthProvider;
|
||||
|
||||
use Hayageek\OAuth2\Client\Provider\Yahoo as HayageekYahoo;
|
||||
|
||||
/**
|
||||
* Wrapper for League Yahoo OAuth2 provider.
|
||||
* @package PHPMailer
|
||||
* @author @hayageek
|
||||
* @author Ravishanker Kusuma (hayageek@gmail.com)
|
||||
* @link https://github.com/hayageek
|
||||
*/
|
||||
|
||||
class Yahoo extends Base
|
||||
{
|
||||
public function getProvider()
|
||||
{
|
||||
if (is_null($this->provider)) {
|
||||
$this->provider = new HayageekYahoo(
|
||||
[
|
||||
'clientId' => $this->oauthClientId,
|
||||
'clientSecret' => $this->oauthClientSecret
|
||||
]
|
||||
);
|
||||
}
|
||||
return $this->provider;
|
||||
}
|
||||
}
|
||||
|
|
@ -269,8 +269,8 @@ class PHPMailer
|
|||
public $AuthType = '';
|
||||
|
||||
/**
|
||||
* An instance of an OAuthProvider\Base derivative class.
|
||||
* @var OAuthProvider\Base
|
||||
* An instance of the PHPMailer OAuth class.
|
||||
* @var OAuth
|
||||
* @access protected
|
||||
*/
|
||||
protected $oauth = null;
|
||||
|
|
@ -3806,8 +3806,8 @@ class PHPMailer
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the OAuthProvider instance.
|
||||
* @return OAuthProvider\Base
|
||||
* Get the OAuth instance.
|
||||
* @return OAuth
|
||||
*/
|
||||
public function getOAuth()
|
||||
{
|
||||
|
|
@ -3815,10 +3815,10 @@ class PHPMailer
|
|||
}
|
||||
|
||||
/**
|
||||
* Set an OAuthProvider instance.
|
||||
* @param OAuthProvider\Base $oauth
|
||||
* Set an OAuth instance.
|
||||
* @param OAuth $oauth
|
||||
*/
|
||||
public function setOAuth(OAuthProvider\Base $oauth)
|
||||
public function setOAuth(OAuth $oauth)
|
||||
{
|
||||
$this->oauth = $oauth;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,8 +332,9 @@ class SMTP
|
|||
* @param string $username The user name
|
||||
* @param string $password The password
|
||||
* @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
|
||||
* @param OAuthProvider\Base $OAuth An optional OAuth provider instance (@see PHPMailerOAuth)
|
||||
* @return bool True if successfully authenticated.* @access public
|
||||
* @param OAuth $OAuth An optional OAuth instance for XOAUTH2 authentication
|
||||
* @return bool True if successfully authenticated.
|
||||
* @access public
|
||||
*/
|
||||
public function authenticate(
|
||||
$username,
|
||||
|
|
|
|||
Loading…
Reference in New Issue