/**
  * @param InboundMessage $message
  */
 public function __construct(InboundMessage $message)
 {
     $this->messageId = $message->getMessageId();
     $this->inReplyTo = $message->getInReplyTo();
     $this->references = $message->getReferences();
     $this->recipients = $message->getRecipients();
     $this->replyTo = $message->getReplyTo();
     $this->fromEmail = $message->getFromEmail();
     $this->fromName = $message->getFromName();
     $this->html = $message->getHtml();
     $this->text = $message->getText();
     $this->subject = $message->getSubject();
     $this->headers = $message->getHeaders();
     $this->deliveredAt = new DateTime('now');
 }
 /**
  * @param array $rawMessage
  * @return InboundMessage
  */
 protected function createInboundMessage(array $rawMessage)
 {
     $rawHeaders = array_change_key_case($rawMessage['headers'], CASE_LOWER);
     $message = new InboundMessage();
     $message->setFromName($rawMessage['from_name']);
     $message->setFromEmail($rawMessage['from_email']);
     $message->setSubject($rawMessage['subject']);
     $message->setText($rawMessage['text']);
     $message->setHtml($rawMessage['html']);
     $message->setMessageId($this->getHeaderValue($rawHeaders, 'message-id'));
     $message->setReplyTo($this->getHeaderValue($rawHeaders, 'reply-to'));
     $message->setInReplyTo($this->getHeaderValue($rawHeaders, 'in-reply-to'));
     $message->setReferences($this->getHeaderValue($rawHeaders, 'references'));
     $message->setHeaders($this->getHeadersFromRawHeaders($rawHeaders));
     $message->setRecipients($this->getRecipientsFromRawMessage($rawMessage));
     $message->setAttachments($this->getAttachmentsFromRawMessage($rawMessage));
     $message->setImages($this->getImagesFromRawMessage($rawMessage));
     return $message;
 }