CodeIgniter Forums
Email library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Email library (/showthread.php?tid=2403)



Email library - El Forum - 08-03-2007

[eluser]Unknown[/eluser]
file: libraries/Email.php

Current code:
Code:
function message($body)
{
    $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
}
The problem is that if you want to use "\r\n" as new-line for the (text) email body you will not succeed. All "\r\n"s will be converted to "\n". (And some SMTP servers will raise an error!).

In order to fix this I added an extra line:
Code:
function message($body)
{
    $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
    $this->_body = str_replace("\n", "".$this->newline, $body);        
}
So it will change all \r\n to \n and after that it will change all \n to whatever new-line character you set.


PS: I didn't fill a Bug Report because I don't know if this is a bug or if I am missing something.