gmail = new Mail; $this->body = new \Google\Service\Gmail\Message(); } protected function doSend(SentMessage $message): void { nlog("in Do Send"); $message = MessageConverter::toEmail($message->getOriginalMessage()); $token = $message->getHeaders()->get('GmailToken')->getValue(); $message->getHeaders()->remove('GmailToken'); // $this->beforeSendPerformed($message); $this->gmail->using($token); $this->gmail->to($message->getTo()[0]->getAddress(), $message->getTo()[0]->getName()); $this->gmail->from($message->getFrom()[0]->getAddress(), $message->getFrom()[0]->getName()); $this->gmail->subject($message->getSubject()); $this->gmail->message($message->getHtmlBody()); $this->gmail->cc($message->getCc()); if(is_array($message->getBcc())) $this->gmail->bcc(array_keys($message->getBcc())); foreach ($message->getAttachments() as $child) { if($child->getContentType() != 'text/plain') { $this->gmail->attach(TempFile::filePath($child->getBody(), $child->getName() )); } } $this->gmail->send(); // $this->gmail->service->users_messages->send('me', $this->body,[]); } public function __toString(): string { return 'gmail'; } }