microsoftgraph / microsoftgraph/msgraph-sdk-php
Sending email : "403 Forbidden" Only for MIME message
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 669
- Forks
- 150
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 3
Description
Hi, I'm using the version 1.110.
I have the following error trying to send an email in MIME type:
Client error: `POST https://graph.microsoft.com/v1.0/users/[EMAIL_ADDRESS]/sendMail` resulted in a `403 Forbidden` response:
{"error":{"code":"ErrorSendAsDenied","message":"The user account which was used to submit this request does not have the right to send mail on behalf of the specified sending account., Cannot submit message."}}
The code used to send is the following:
$requestUrl = '/users/' . $username . '/sendMail';
$emailResponse = $this->graphClient->createRequest('POST', $requestUrl)
->addHeaders(["Content-Type" => "text/plain"])
->attachBody(base64_encode(serialize([
"Content-Type" => "text/plain",
'message' => $mimeContent
])))->execute();
With the same email account, if I send an email in Json format I do not have any error.
Any Idea how to solve?
Thanks
Francesco
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PHP request at createRequest('POST', '/users/.../sendMail') and compare its MIME body and headers with the JSON request that succeeds. Check the Microsoft Graph sendMail requirements for MIME messages; done means identifying whether the request is malformed or the account lacks permission and documenting the required correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100