From 1186bc56f194defe827dd0802ea17cc243b5b836 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 27 Nov 2010 02:11:43 +0530 Subject: [PATCH] Adding EmailCompnent::lineFeed property toallow overriding the default line feed string when using mail() function to send mail. Closes #1320 --- cake/libs/controller/components/email.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index d27fd5c13fc..2aa96c3e01a 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -98,7 +98,7 @@ class EmailComponent extends Object{ var $bcc = array(); /** - * The date to put in the Date: header. This should be a date + * The date to put in the Date: header. This should be a date * conformant with the RFC2822 standard. Leave null, to have * today's date generated. * @@ -157,6 +157,18 @@ class EmailComponent extends Object{ */ var $lineLength = 70; +/** + * Line feed character(s) to be used when sending using mail() function + * If null PHP_EOL is used. + * RFC2822 requires it to be CRLF but some Unix + * mail transfer agents replace LF by CRLF automatically + * (which leads to doubling CR if CRLF is used). + * + * @var string + * @access public + */ + var $lineFeed = null; + /** * @deprecated see lineLength */ @@ -804,8 +816,13 @@ function _strip($value, $message = false) { * @access private */ function _mail() { - $header = implode("\r\n", $this->__header); - $message = implode("\r\n", $this->__message); + if ($this->lineFeed === null) { + $lineFeed = PHP_EOL; + } else { + $lineFeed = $this->lineFeed; + } + $header = implode($lineFeed, $this->__header); + $message = implode($lineFeed, $this->__message); if (is_array($this->to)) { $to = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); } else {