Skip to content

Commit

Permalink
Adding EmailCompnent::lineFeed property toallow overriding the defaul…
Browse files Browse the repository at this point in the history
…t line feed string when using mail() function to send mail. Closes #1320
  • Loading branch information
ADmad committed Nov 26, 2010
1 parent 70ae66e commit 1186bc5
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cake/libs/controller/components/email.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 {
Expand Down

1 comment on commit 1186bc5

@Phally
Copy link
Contributor

@Phally Phally commented on 1186bc5 Jan 20, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about: var $lineFeed = PHP_EOL; and remove that entire IF block?

Please sign in to comment.