/** * @return Tracker_Artifact_MailGateway_IncomingMessage */ public function build(array $raw_mail) { if (!isset($raw_mail['headers']['references'])) { throw new Tracker_Artifact_MailGateway_InvalidMailHeadersException(); } preg_match(Tracker_Artifact_MailGateway_RecipientFactory::EMAIL_PATTERN, $raw_mail['headers']['references'], $matches); $recipient = $this->recipient_factory->getFromEmail($matches[0]); $subject = $raw_mail['headers']['subject']; $body = $raw_mail['body']; $incoming_message = new Tracker_Artifact_MailGateway_IncomingMessage($raw_mail['headers'], $subject, $body, $recipient->getUser(), $recipient->getArtifact()->getTracker(), $recipient->getArtifact()); return $incoming_message; }
private function getRecipient(stdClass $structure) { preg_match(Tracker_Artifact_MailGateway_RecipientFactory::EMAIL_PATTERN, $structure->headers['references'], $matches); return $this->recipient_factory->getFromEmail($matches[0]); }