Permalink
Browse files

Merge branch 'feature/mail-message-from-string' of https://github.com…

…/Xerkus/zf2 into feature/mail-from-string
  • Loading branch information...
2 parents 2bc0fe7 + bedd30b commit dafb61b3dd1f6857770c6144a225f54fa396e9c8 @weierophinney weierophinney committed Sep 13, 2012
Showing with 123 additions and 91 deletions.
  1. +20 −0 library/Zend/Mail/Message.php
  2. +103 −91 tests/ZendTest/Mail/MessageTest.php
@@ -535,4 +535,24 @@ public function toString()
. Headers::EOL
. $this->getBodyText();
}
+
+ /**
+ * Instantiate from raw message string
+ *
+ * @param string $rawMessage
+ * @return Message
+ */
+ public static function fromString($rawMessage)
+ {
+ $message = new static();
+ $headers = null;
+ $content = null;
+ Mime\Decode::splitMessage($rawMessage, $headers, $content);
+ if ($headers->has('mime-version')) {
+ // @todo restore body to mime\message
+ }
+ $message->setHeaders($headers);
+ $message->setBody($content);
+ return $message;
+ }
}
Oops, something went wrong.

0 comments on commit dafb61b

Please sign in to comment.