How to send messages in MIME format?
Opened this issue · 3 comments
The documentation asserts that the Graph API supports sending E-Mails using the MIME format.
While previous versions of this SDK still gave access to simply building a new request to whatever URL, the current version is not as simple anymore.
May I kindly ask for some guidance, on how to send E-Mails in the MIME format using the current version of this SDK?
Good morning @GenieTim , did you implement the send in mime format? We have implemented but recently we have a problem with the versione 1.110
No, sorry, @francescodiperna , I did not. Would still be thankful for pointers, whether there is, or will be, a possibility to do it with this library, or whether I have to do it "raw"
Good morning, @GenieTim. I did, using the versione 1.110, below the code.
private function inviaEmailMicrosoft($mimeContent, $username)
{
$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();
if ($emailResponse->getStatus() == 400) {
throw new \Exception("ATTENZIONE! impossibile inviare il messaggio dell'utente " . $username .
"Invalid base64 string for MIME content");
}
if ($emailResponse->getStatus() != 202) {
throw new \Exception("ATTENZIONE! impossibile inviare il messaggio dell'utente " . $username);
}
return true;
}