[eluser]sophistry[/eluser]
welcome to CI leviathan!
yes, you found out that the Email.php file strips multiple spaces.
here is the code from Email.php (the stripping happens right at the top, but i included the whole word_wrap() method for fun):
my advice is comment out the preg_ command that strips spaces. you could also make a MY_Email.php class and override the functionality with your own word_wrap() method. and you could file abug report and see if it sticks. i haven't had this issue, but haven't tried to format with text/plain (i usually do it with HTML because the client email reader can also do ungracious things to your text/plain emails like render them in non-monospace fonts and such.)
cheers.
Code:
/**
* Word Wrap
*
* @access public
* @param string
* @param integer
* @return string
*/
function word_wrap($str, $charlim = '')
{
// Se the character limit
if ($charlim == '')
{
$charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
}
// Reduce multiple spaces
$str = preg_replace("| +|", " ", $str);
// Standardize newlines
if (strpos($str, "\r") !== FALSE)
{
$str = str_replace(array("\r\n", "\r"), "\n", $str);
}
// If the current word is surrounded by {unwrap} tags we'll
// strip the entire chunk and replace it with a marker.
$unwrap = array();
if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
{
for ($i = 0; $i < count($matches['0']); $i++)
{
$unwrap[] = $matches['1'][$i];
$str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
}
}
// Use PHP's native function to do the initial wordwrap.
// We set the cut flag to FALSE so that any individual words that are
// too long get left alone. In the next step we'll deal with them.
$str = wordwrap($str, $charlim, "\n", FALSE);
// Split the string into individual lines of text and cycle through them
$output = "";
foreach (explode("\n", $str) as $line)
{
// Is the line within the allowed character count?
// If so we'll join it to the output and continue
if (strlen($line) <= $charlim)
{
$output .= $line.$this->newline;
continue;
}
$temp = '';
while((strlen($line)) > $charlim)
{
// If the over-length word is a URL we won't wrap it
if (preg_match("!\[url.+\]|://|wwww.!", $line))
{
break;
}
// Trim the word down
$temp .= substr($line, 0, $charlim-1);
$line = substr($line, $charlim-1);
}
// If $temp contains data it means we had to split up an over-length
// word into smaller chunks so we'll add it back to our current line
if ($temp != '')
{
$output .= $temp.$this->newline.$line;
}
else
{
$output .= $line;
}
$output .= $this->newline;
}
// Put our markers back
if (count($unwrap) > 0)
{
foreach ($unwrap as $key => $val)
{
$output = str_replace("{{unwrapped".$key."}}", $val, $output);
}
}
return $output;
}