1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Fixes for sending via graph

This commit is contained in:
David Bomba 2022-07-15 17:03:32 +10:00
parent a626858752
commit 164b8c41aa

View File

@ -34,19 +34,19 @@ class Office365MailTransport extends AbstractTransport
$graph = new Graph(); $graph = new Graph();
$token = $symfony_message->getHeaders()->get('GmailToken')->getValue(); $token = $symfony_message->getHeaders()->get('GmailToken')->getValue();
$message->getHeaders()->remove('GmailToken'); $symfony_message->getHeaders()->remove('GmailToken');
$graph->setAccessToken($token); $graph->setAccessToken($token);
try { try {
$graphMessage = $graph->createRequest('POST', '/users/'.$this->getFrom().'/sendmail') $graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
->attachBody(base64_encode($message->toString())) ->attachBody(base64_encode($message->toString()))
->addHeaders(['Content-Type' => 'text/plain']) ->addHeaders(['Content-Type' => 'text/plain'])
->setReturnType(\Microsoft\Graph\Model\Message::class) ->setReturnType(\Microsoft\Graph\Model\Message::class)
->execute(); ->execute();
} catch (\Exception $e) { } catch (\Exception $e) {
sleep(5); sleep(5);
$graphMessage = $graph->createRequest('POST', '/users/'.$this->getFrom().'/sendmail') $graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
->attachBody(base64_encode($message->toString())) ->attachBody(base64_encode($message->toString()))
->addHeaders(['Content-Type' => 'text/plain']) ->addHeaders(['Content-Type' => 'text/plain'])
->setReturnType(\Microsoft\Graph\Model\Message::class) ->setReturnType(\Microsoft\Graph\Model\Message::class)
@ -55,11 +55,6 @@ class Office365MailTransport extends AbstractTransport
} }
private function getFrom()
{
return 'turbo124@outlook.com.au';
}
private function base64_encode($data) private function base64_encode($data)
{ {
return rtrim(strtr(base64_encode($data), ['+' => '-', '/' => '_']), '='); return rtrim(strtr(base64_encode($data), ['+' => '-', '/' => '_']), '=');