Closed jordm closed 2 years ago
When trying to send, try using a scope of only ‘https://outlook.office.com/SMTP.Send' If you use scopes that are specifically Graph such as User.Read or Mail.Send, MSFT tries to use the Graph API resource rather than outlook.office.com and fails. Your error may be a side-effect of this.
I probably spotted the issue, you are using Mail.Send with Application-level permissions, not delegated in your AAD:
Pls ignore my earlier comment. I had assumed you were wishing to OAUTH2 authenticate for SMTP sending and had used Graph's Mail.Send in the scope - which combination doesn't work as the resource that implements OAUTH2-authenticated SMTP is the Exchange API and not Graph and you cannot mix resources in one authorisation token.
I am just starting to learn this so I apologize if I'm butchering the implementation. When trying to use Mail.Send scope and am met with this error:
invalid_grant AADSTS65001: The user or administrator has not consented to use the application with ID
although I've consented to all permissions through azure portal -> app registration -> api permissions as well as azure portal-> enterprise applications -> permissions.
I have users sign in using v2.0 and save the token in
$_SESSION['aToken']
and the refresh token in$_SESSION['rToken']
When calling my sendmail script I include my provider file
and in sendmail:
When removing the mail.send scope
$me
has all expected variable