Skip to content

Commit

Permalink
add OAUTH pseudo method
Browse files Browse the repository at this point in the history
   * OAUTH pseudo method will elect either XOAUTH2 or OAUTHBEARER according to server's capabilities

Signed-off-by: Edouard Vanbelle <[email protected]>
  • Loading branch information
EdouardVanbelle committed Dec 26, 2023
1 parent 8a06d24 commit 6451805
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Net/SMTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ public function starttls()
* @param string $pwd The password to authenticate with.
* @param string $method The requested authentication method. If none is
* specified, the best supported method will be used.
* If you use the special method `OAUTH`, the best
* supported method will be between XOAUTH2 and OAUTHBEARER
* @param bool $tls Flag indicating whether or not TLS should be attempted.
* @param string $authz An optional authorization identifier. If specified, this
* identifier will be used as the authorization proxy.
Expand Down Expand Up @@ -750,6 +752,14 @@ public function auth($uid, $pwd , $method = '', $tls = true, $authz = '')
/* Return the PEAR_Error object from _getBestAuthMethod(). */
return $method;
}
} elseif ($method === 'OAUTH') {
// case of OAUTH, elect the best method
$available_methods = explode(' ', $this->esmtp['AUTH']);
foreach (['XOAUTH2', 'OAUTHBEARER'] as $method) {
if (in_array($method, $available_methods)) {
break;
}
}
} else {
$method = strtoupper($method);
if (!array_key_exists($method, $this->auth_methods)) {
Expand Down

0 comments on commit 6451805

Please sign in to comment.