Skip to content

Commit

Permalink
Workaround for Zend\Mail\Storage\Message parser
Browse files Browse the repository at this point in the history
zendframework/zend-mail#159

Current workaround is to split headers+body ourselves from raw message.
  • Loading branch information
glensc committed Sep 4, 2017
1 parent 02b6fe2 commit 5d06ccc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Mail/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,22 @@ public static function createNew()
*/
public static function createFromString($raw)
{
$message = new self(['root' => true, 'raw' => $raw]);
// do our own header-body splitting.
//
// \Zend\Mail\Storage\Message is unable to process mails that contain \n\n in text body
// because it has heuristic which headers separator to use
// and that gets out of control
// https://github.com/zendframework/zend-mail/pull/159

// use rfc compliant "\r\n" EOL
try {
Mime\Decode::splitMessage($raw, $headers, $content, "\r\n");
} catch (Mail\Exception\RuntimeException $e) {
// retry with heuristic
Mime\Decode::splitMessage($raw, $headers, $content);
}

$message = new self(['root' => true, 'headers' => $headers, 'content' => $content]);

return $message;
}
Expand Down

0 comments on commit 5d06ccc

Please sign in to comment.