79188098

Date: 2024-11-14 09:43:33
Score: 2
Natty:
Report link

I tested this code, phpmailer make it loop indefinetly.

I use a provider requesting several scopes, put the token in a session, and used a class.

$provider = new TheNetworg\OAuth2\Client\Provider\Azure([
            'clientId'          => 'xyz',
            'clientSecret'      => 'xyz',
            'tenantId' => 'xyz',
            'redirectUri'       => 'http://localhost/myurl',
            'scopes'            => ['openid profile email offline_access https://outlook.office.com/SMTP.Send'],
            'defaultEndPointVersion' => '2.0',
            'accessType' => 'offline'
        ]);

class MyTokenProvider implements OAuthTokenProvider{

public function getOauth64(){
    return base64_encode(
        'user=' .
        $_SESSION['userEmail'].
        "\001auth=Bearer " .
        $_SESSION['token'].
        "\001\001"
    );
}

then

$myOwnOauth = new MyTokenProvider();

$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAuth = true;
$mail->AuthType = 'XOAUTH2';
$mail->setOAuth($myOwnOauth );

etc

phpmailer then loop non stop, microsoft displaying too many requests and after several minutes : SMTP ERROR: AUTH command failed: 535 5.7.3 Authentication unsuccessful I'm able to mail with graph api with the token but can't make it works with phpmailer.

is there something i missed?

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Yann