Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding EmailCompnent::lineFeed property toallow overriding the defaul…

…t line feed string when using mail() function to send mail. Closes #1320
  • Loading branch information...
commit 1186bc56f194defe827dd0802ea17cc243b5b836 1 parent 70ae66e
@ADmad ADmad authored
Showing with 20 additions and 3 deletions.
  1. +20 −3 cake/libs/controller/components/email.php
View
23 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.
*
@@ -158,6 +158,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
*/
var $_lineLength = null;
@@ -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 {

1 comment on commit 1186bc5

@Phally
Collaborator

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

Please sign in to comment.
Something went wrong with that request. Please try again.