getOriginalMessage()); $graph = new Graph(); $token = $symfony_message->getHeaders()->get('gmailtoken')->getValue(); $symfony_message->getHeaders()->remove('gmailtoken'); $graph->setAccessToken($token); try { $graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail') ->attachBody(base64_encode($message->toString())) ->addHeaders(['Content-Type' => 'text/plain']) ->setReturnType(\Microsoft\Graph\Model\Message::class) ->execute(); } catch (\Exception $e) { sleep(5); $graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail') ->attachBody(base64_encode($message->toString())) ->addHeaders(['Content-Type' => 'text/plain']) ->setReturnType(\Microsoft\Graph\Model\Message::class) ->execute(); } } public function __toString(): string { return 'office365'; } }