Sending mail in PHP application using Graph API not working

Jelle Tempelman 21 Reputation points
2021-09-28T15:04:22.537+00:00

When trying to send a POST request to "/users/{email}/sendMail" I get an error 403 telling me
"Access is denied. Check credentials and try again."
But my application do have the right permissions (see screenshot)
135878-screenshot-2021-09-28-at-170159.png
Same goes the API explorer. It's telling me "You need to consent to permissions on the Modify permissions (preview) tab" but on the preview tab, all the permissions are consented.
135927-screenshot-2021-09-28-at-165516.png
What is going wrong?

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
207 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,581 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-09-29T07:20:34.103+00:00

    Hi @Jelle Tempelman ,

    You may misunderstand the delegated permissions and application permissions.

    From the screenshot, your apps are using delegated permissions. And delegated permissions are used by apps that have a signed-in user present.

    If you want you app run without a signed-in user present, you should use application permissions.

    You could refer to this about delegated permissions and application permissions: https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#permission-types

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-09-29T06:21:22.287+00:00

    Hi @Jelle Tempelman ,

    Seems like you are trying send emaail from another user. To achieve this, mailbox permissions also need to be granted in exchange online. Please refer to this article for more: https://learn.microsoft.com/en-us/graph/outlook-send-mail-from-other-user

    136163-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Jelle Tempelman 21 Reputation points
    2021-09-29T06:49:18.017+00:00

    Hi @MichaelHan-MSFT , thanks for responding. I hope we can work this out together, because I'm a bit lost...

    I don't quite understand what you're implying. Under my Azure services -> App registrations I have an application. I'm trying to send email from my PHP web application using the API permissions of this Azure application. I don't understand what you mean with "sending mail from another user". That in my eyes seems a little weird, since my Azure application is not a user nor a mailbox itself, so I have no other choice than sending from "another" user.

    0 comments No comments