Add support for empty tokens

This commit is contained in:
Marcus Bointon 2025-06-18 19:37:59 +02:00
parent 90cdf758c2
commit ce9d1b6883
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
1 changed files with 7 additions and 1 deletions

View File

@ -639,7 +639,13 @@ class SMTP
* If the token is longer than that, the command and the token must be sent separately as described in
* https://www.rfc-editor.org/rfc/rfc4954#section-4
*/
if (strlen($oauth) <= 497) {
if ($oauth === '') {
//Sending an empty auth token is legitimate, but it must be encoded as '='
//to indicate it's not a 2-part command
if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 =', 235)) {
return false;
}
} elseif (strlen($oauth) <= 497) {
//Authenticate using a token in the initial-response part
if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
return false;