getOriginalMessage()); $token = $message->getHeaders()->get('gmailtoken')->getValue(); $message->getHeaders()->remove('gmailtoken'); $client = new Client(); $client->setClientId(config('ninja.auth.google.client_id')); $client->setClientSecret(config('ninja.auth.google.client_secret')); $client->setAccessToken($token); $service = new Gmail($client); $body = new Message(); $body->setRaw($this->base64_encode($message->toString())); $service->users_messages->send('me', $body, []); } private function base64_encode($data) { return rtrim(strtr(base64_encode($data), ['+' => '-', '/' => '_']), '='); } public function __toString(): string { return 'gmail'; } }