I ran into a few problems with this one:
1) Line 32 -- str_replace() code.
After much hair-pulling, I discovered that the only way I could get this to work was by preceding the backslash r and backslash n items with an additional backslash. ie:
$value = str_replace("\\r","\\n","%0a","%0d");
This was true for my own computer, as well as 2 different web hosts.
2) Mail delays.
I put the code on one of my sites and it worked perfectly. But when I copied it onto another site with a different webhost (with the necessary changes), it didn't APPEAR to work at all...
The next morning however, I found that the mail from the second site did indeed get sent...1 or 2 hours after I sent it. Something to do with the caching system of the mail server of that particular web host.
Moral of the story: if you hit "Submit" and the email doesn't get sent right away, it may not be your code's fault.
3) Magic quotes.
Both my web hosts have 'Magic quotes' on, so I used the following to remove the added slashes:
if(get_magic_quotes_gpc()){
$_POST['name'] = stripslashes($_POST['name']);
$_POST['email'] = stripslashes($_POST['email']);
$_POST['comments'] = stripslashes($_POST['comments']);
}