Skip to content

Commit 5d06ccc

Browse files
committed
Workaround for Zend\Mail\Storage\Message parser
zendframework/zend-mail#159 Current workaround is to split headers+body ourselves from raw message.
1 parent 02b6fe2 commit 5d06ccc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Mail/MailMessage.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,22 @@ public static function createNew()
9797
*/
9898
public static function createFromString($raw)
9999
{
100-
$message = new self(['root' => true, 'raw' => $raw]);
100+
// do our own header-body splitting.
101+
//
102+
// \Zend\Mail\Storage\Message is unable to process mails that contain \n\n in text body
103+
// because it has heuristic which headers separator to use
104+
// and that gets out of control
105+
// https://github.com/zendframework/zend-mail/pull/159
106+
107+
// use rfc compliant "\r\n" EOL
108+
try {
109+
Mime\Decode::splitMessage($raw, $headers, $content, "\r\n");
110+
} catch (Mail\Exception\RuntimeException $e) {
111+
// retry with heuristic
112+
Mime\Decode::splitMessage($raw, $headers, $content);
113+
}
114+
115+
$message = new self(['root' => true, 'headers' => $headers, 'content' => $content]);
101116

102117
return $message;
103118
}

0 commit comments

Comments
 (0)