From dbb77bf1253f38eda8598393ad09cf068e2578d1 Mon Sep 17 00:00:00 2001 From: chrip Date: Wed, 12 Oct 2022 10:02:11 +0200 Subject: [PATCH] Fix wrong line ending in email header when using MailTransport. --- lib/Cake/Network/Email/MailTransport.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Network/Email/MailTransport.php b/lib/Cake/Network/Email/MailTransport.php index 36782b2f1..3cfb0cc66 100644 --- a/lib/Cake/Network/Email/MailTransport.php +++ b/lib/Cake/Network/Email/MailTransport.php @@ -32,7 +32,10 @@ class MailTransport extends AbstractTransport { * @throws SocketException When mail cannot be sent. */ public function send(CakeEmail $email) { - $eol = PHP_EOL; + + // https://github.com/cakephp/cakephp/issues/2209 + // https://bugs.php.net/bug.php?id=47983 + $eol = "\r\n"; if (isset($this->_config['eol'])) { $eol = $this->_config['eol']; } @@ -40,11 +43,11 @@ class MailTransport extends AbstractTransport { $to = $headers['To']; unset($headers['To']); foreach ($headers as $key => $header) { - $headers[$key] = str_replace(array("\r", "\n"), '', $header); + $headers[$key] = str_replace("\r\n", '', $header); } $headers = $this->_headersToString($headers, $eol); - $subject = str_replace(array("\r", "\n"), '', $email->subject()); - $to = str_replace(array("\r", "\n"), '', $to); + $subject = str_replace("\r\n", '', $email->subject()); + $to = str_replace("\r\n", '', $to); $message = implode($eol, $email->message());