PHP email

Hi everyone…
I’m back again with a question about whether anyone knows PHP well enough to help me. I already have an emailing script all set up and implemented. What I want to know is how to send rich-text/HTML emails. I can’t get the

$content=  $_POST['Message'];

command to send rich text. When I try sending HTML code, it changes it so that you view, for example,


but when you look at the source, it is really


. How do I turn this off and make it send what I originally entered and not translate it?

Does this help?:

Did you set: Content-type: text/html

in the mailheaders???

I don’t know how to set things in the mail headers. I am using a script that looks like this:

mail($mailto, $subject, $content, "From: $from");

and I have the variables stored elsewhere. I took a very careful look and realized that the problem wasn’t as I originally described. You’re totally right, macouno. Do you know how to set Content-type: text/html in the mail headers?

Never mind! I figured it out by a few minutes on Google. Here’s the new snippett:

$headers = "MIME-Version: 1.0
$headers .= "Content-type: text/html; charset=iso-8859-1
$headers .= "From: $from";

mail($mailto, $subject, $content, $headers);

My new question is: How do you get rid of the \ before all of the quotes? Isn’t it supposed to delete those when it generates the email? It does when it generates HTML to display in the browser…

To remove the quotes:

$content = stripslashes($_POST[‘Message’]);

If magic_quotes is set for the PHP install you have, all quotes submitting in a post will be escaped with a .


All right! It works great now! If you want the script, here it is… (except I removed the email address)

form section of email.htm:

<form name="email" method="post" action="send.php" enctype="multipart/form-data">

  <table border="0" cellspacing="0" cellpadding="2" width="325">
        &lt;td valign="top" width="156"&gt;&lt;font size="2" face="Arial"&gt;<b>To:</b>&lt;/font&gt;&lt;/td&gt;
        &lt;td width="144"&gt;&lt;font size="2" face="Arial"&gt;<b>&lt;input
        type="text" size="20" name="To"&gt; </b>&lt;/font&gt;&lt;/td&gt;
        &lt;td valign="top" width="156"&gt;&lt;font size="2" face="Arial"&gt;<b>Your Email:</b>&lt;/font&gt;&lt;/td&gt;
        &lt;td width="144"&gt;&lt;font size="2" face="Arial"&gt;<b>&lt;input
        type="text" size="20" name="Email"&gt; </b>&lt;/font&gt;&lt;/td&gt;
        &lt;td valign="top" width="156"&gt;&lt;font size="2" face="Arial"&gt;<b>Subject:</b>&lt;/font&gt;&lt;/td&gt;
        &lt;td width="144"&gt;&lt;font size="2" face="Arial"&gt;<b>&lt;input
        type="text" size="40" name="Subject"&gt; </b>&lt;/font&gt;&lt;/td&gt;
        &lt;td valign="top" width="156"&gt;&lt;font size="2" face="Arial"&gt;<b>Message:</b>&lt;/font&gt;&lt;/td&gt;
        &lt;td width="144"&gt;&lt;textarea name="Message" rows="20"
        cols="60"&gt;&lt;/textarea&gt; &lt;/td&gt;

  &lt;input type="submit" name="button1" value="Submit"&gt;
  &lt;input type="reset" name="button2" value="Reset"&gt;




$mailto=   $_POST['To'];
$subject=  $_POST['Subject'];
$from=     $_POST['Email'];
$content=  stripslashes($_POST['Message']);

$new_url=  "";

$headers = "MIME-Version: 1.0
$headers .= "Content-type: text/html; charset=iso-8859-1
$headers .= "From: $from";

mail($mailto, $subject, $content, $headers);

     if (isset($new_url)){
     header ("Location: $new_url");


Here’s my email page: