Permalink
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...
1 parent 156a708 commit 93a46cdc323ce83b2645052031d745ed98f862e3 @ADmad ADmad committed Nov 26, 2010
Showing with 21 additions and 3 deletions.
  1. +21 −3 cake/libs/controller/components/email.php
@@ -94,7 +94,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.
*
@@ -147,6 +147,19 @@ class EmailComponent extends Object{
* @access public
*/
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
*/
@@ -674,8 +687,13 @@ function __strip($value, $message = false) {
* @access private
*/
function __mail() {
- $header = implode("\n", $this->__header);
- $message = implode("\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 (ini_get('safe_mode')) {
return @mail($this->to, $this->__encode($this->subject), $message, $header);
}

0 comments on commit 93a46cd

Please sign in to comment.