Jump to content

nl2br($string) vs. str_replace("\n","<br />","$string"); before using mail();


Recommended Posts

I've got a script that sends mail based on quiz answers that are stored in an xml file. The answers have \n newline characters in them, which I convert to

<br />

before generating the HTML portion of a multipart email. I was experiencing problems using str_replace to replace all of the \n with

<br />

, but nl2br works fine. What is strange is, when using str_replace, I can check the value of the converted string with echo and it looks just as I want, but the mail() function won't accept the string, and mail() fails. Using nl2br works great. I just want to know why the string generated by str_replace isn't accepted by the mail function.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.