gmail = $gmail; $this->token = $token; } public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { /*We should nest the token in the message and then discard it as needed*/ $this->beforeSendPerformed($message); $this->gmail->using($this->token); $this->gmail->to($message->getTo()); $this->gmail->from($message->getFrom()); $this->gmail->subject($message->getSubject()); $this->gmail->message($message->getBody()); //$this->gmail->message($message->toString()); $this->gmail->cc($message->getCc()); $this->gmail->bcc($message->getBcc()); foreach ($message->getChildren() as $child) { nlog("trying to attach"); nlog($child->getContentType()); if($child->getContentType() != 'text/plain'){ nlog($child->getHeaders()); $this->gmail->attach(TempFile::filePath($child)); } foreach ($message->getChildren() as $child) { nlog("trying to attach"); if($child->getContentType() != 'text/plain'){ // $attachment = (new Swift_Attachment()) // ->setFilename($child->getHeaders()->get('Content-Type')->getParameter('name')) // ->setContentType($child->getContentType()) // ->setBody($child->getBody()); $this->gmail->attach(new Swift_Attachment($child)); } } //todo this should 'just work' } //todo this should 'just work' $this->gmail->send(); $this->sendPerformed($message); return $this->numberOfRecipients($message); } }