Jump to content

Extra Characters in PHP Email


parrothead

Recommended Posts

I have an email form that I use to generate email messages to a club distribution list. I add the body of the message from a form that sends that message to a php script. The emails are a mix of html directly from the script as well as what is sent to the script from the web page form.

 

Example:

$mailmessage = '<html><body>header of message' . $MessageFromForm . 'footer of message </body></html>';

 

**where $MessageFromForm is requested from the form and is the body of the email message.

 

The html header and footer of the message look fine, but the code that came from my html form does not work properly. That code replaces a ' with \', and the html tags do not work. I do have the following included in my headers:

 

$headers = "MIME-Version: 1.0" . "\n";

$headers .= "Content-type:text/html;charset=iso-8859-1" . "\n";

 

Any ideas on what could cause this?

 

 

Link to comment
Share on other sites

from php.net

$to = 'email@domain.com, email2@domain.com';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

Link to comment
Share on other sites

If you're getting data from a form that has backslashes escaping the quotes, you probably have magic_quotes_gpc() set to ON in your php.ini file. If phpinfo() shows it to be On, and you are able to do so, set it to Off.

 

THANK YOU! I spent hours trying to figure out what was causing this. It was magic quotes. I used stripslashes on my variable to fix the issue. I think this must have happened when the PHP version switched as this problem did not exist before. I really appreciate the help!

Link to comment
Share on other sites

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.