Anyone attempting to write a text email client should be aware of the following:
<?php
$a = "some text that must wrap nice";
$a = wordwrap($a, 9);
echo $a;
// some text
// that must
// wrap nice
$a = wordwrap($a, 9);
echo $a;
// some text
// that
// must
// wrap
// nice
?>
Subsequent uses of wordwrap() on already wrapped text will take the end-of-line characters into account when working out line length, thus reading each line that just fit nicely the first time around as being one character too long the second. This can be a problem when preparing a text email that contains (eg.) a forwarded email which has already been word-wrapped.
Solutions below which explode() the text on end-of-lines and wordwrap() the resulting strings separately take care of this nicely.