Sending email from form - can't get html though

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jsavagedesign
    New Member
    • Jun 2007
    • 17

    Sending email from form - can't get html though

    I am trying to send and email from a form using php. I got that to work.
    The problem is that when I receve the email it is a text version with all the html tags showing.

    looks like this:
    Code:
    <HTML><HEAD><TITLE></TITLE></HEAD><BODY><table width="440" border="1" cellspacing="0" cellpadding="3"><tr><td colspan="2"><em>The following was receved from the General Estimate form</em></td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>I am interested in these type(s) of relocation:</strong></td></tr><tr><td colspan="2"><ul><li>Commercial</li><li>International</li></ul></td></tr><tr><td colspan="2" style="background-color:#2362ac; color:#FFFFFF;"><strong>Contact Info:</strong></td></tr><tr><td>Name</td> <td>jason</td></tr><tr><td>Company Name</td> <td>questfore</td></tr><tr><td>Phone Number</td> <td>234-567-8907</td></tr><tr><td>Best Time to Contact</td> <td>Morning</td></tr><tr><td>Email</td> <td>jasons@questfore.com</td></tr><tr><td>City</td> <td>pittsburgh</td></tr><tr><td>State</td> <td>pa</td></tr><tr><td>Zip</td> <td>15203</td></tr><tr><td>Country</td> <td>use</td></tr><tr><td>DesCity</td> <td>imperial</td></tr><tr><td>DesState</td!
    > <td>pa</td></tr><tr><td>DesZip</td> <td>15126</td></tr><tr><td 
    > colspan="2" style="background-color:#2362ac; 
    > color:#FFFFFF;"><strong>Special 
    > Circumstances:</strong></td></tr><tr><td>PackSrv</td> 
    > <td>yes</td></tr><tr><td>Storage</td> <td>no</td></tr><tr><td 
    > colspan="2" style="background-color:#2362ac; 
    > color:#FFFFFF;"><strong>How did you hear about 
    > Weleski?:</strong></td></tr><tr><td 
    > colspan="2"><ul><li>Television</li><li>Invite</li><li>Web</li><li>&nbs
    > p;</li></ul></td></tr></table></BODY></HTML>
    should look like this: (tags shouldn't be showing only a table with all data)
    [code=html]
    <table width="440" border="1" cellspacing="0" cellpadding="3" ><tr><td colspan="2"><em >The following was receved from the General Estimate form</em></td></tr><tr><td colspan="2" style="backgrou nd-color:#2362ac; color:#FFFFFF;" ><strong>I am interested in these type(s) of relocation:</strong></td></tr><tr><td colspan="2"><ul ><li>Commercial </li><li>Internat ional</li></ul></td></tr><tr><td colspan="2" style="backgrou nd-color:#2362ac; color:#FFFFFF;" ><strong>Contac t Info:</strong></td></tr><tr><td>Name </td> <td>jason</td></tr><tr><td>Comp any Name</td> <td>questfore </td></tr><tr><td>Phon e Number</td> <td>234-567-8907</td></tr><tr><td>Best Time to Contact</td> <td>Morning</td></tr><tr><td>Emai l</td> <td>jasons@ques tfore.com</td></tr><tr><td>City </td> <td>pittsburg h</td></tr><tr><td>Stat e</td> <td>pa</td></tr><tr><td>Zip</td> <td>15203</td></tr><tr><td>Coun try</td> <td>use</td></tr><tr><td>DesC ity</td> <td>imperial</td></tr><tr><td>DesS tate</td> <td>pa</td></tr><tr><td>DesZ ip</td> <td>15126</td></tr><tr><td colspan="2" style="backgrou nd-color:#2362ac; color:#FFFFFF;" ><strong>Specia l Circumstances:</strong></td></tr><tr><td>Pack Srv</td> <td>yes</td></tr><tr><td>Stor age</td> <td>no</td></tr><tr><td colspan="2" style="backgrou nd-color:#2362ac; color:#FFFFFF;" ><strong>How did you hear about Weleski?:</strong></td></tr><tr><td colspan="2"><ul ><li>Television </li><li>Invite</li><li>Web</li><li>&nbsp;</li></ul></td></tr></table>[/code]

    Please help, I think it has something to do with the header data but I don't know what to put.

    Thanks
    - Jason
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Jason.

    To send an HTML Email, you need to set a couple of headers.

    Check out this example.

    Comment

    • jsavagedesign
      New Member
      • Jun 2007
      • 17

      #3
      Thanks for the link. I inserted the code for the header and still no luck.
      Could it be a php security thing?

      here us the code i am using:

      [PHP]
      $cancelSubmissi on = false;
      if(!isset($_POS T['formName'])){exit('Error: no form name found!');}
      //if(!isset($_POS T['submit'])) {exit('Error: submit was not pushed!');}

      //This value defines the subject
      $strSubject = "Message from the website - form: " . $_POST['formName'];

      //This value defines the sender and receiver email addresses
      $strSender = "" //where the email is from (probaly don't need this, it's automaticly generated by the server)
      $strReceiver = "" //my email address

      //This value defines the re-direction of the browser after submission
      $strRedirectURL = 'acknowledgemen t.htm';

      //This value defines body of the email

      //a bunch of code that cleans up the form data for the client
      //it creates the muli-dimentional array used below

      //Create table with titles for each section
      $strMessage = "<HTML><HEAD><T ITLE></TITLE></HEAD><BODY>";

      if($fArrayMulti[0][1] == "general_es t" ){

      //a bunch of code that makes the table
      }
      //Check to make sure email is not garbage
      if(($fArrayMult i[$part[0]][1] == '&nbsp;' || $fArrayMulti[$part[0]][1] == '') && ($fArrayMulti[$part[0]+2][1] == '&nbsp;' || $fArrayMulti[$part[0]+2][1] == '')){
      $cancelSubmissi on = true;
      }



      //Compile mail and send it

      //if(cancelSubmis sion != true){
      //add header
      // 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";

      if(mail($strRec eiver, $strSubject, $strMessage, $header)){
      echo "Mail Sent.";
      }else{
      echo "Error sending email! Message not sent!";
      }

      //JS_redirect( $strRedirectURL );

      //}else{
      //JS_redirect("../../home.htm");
      //print("Submissi on canceled");
      //}[/PHP]

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Jason.

        When you send the mail, you use $header instead of $headers. Is this intentional?

        Comment

        • jsavagedesign
          New Member
          • Jun 2007
          • 17

          #5
          YOUR a freakn genius!

          and i feel retarded...

          I must have copied code a while ago and never changed it in the mail() function
          Thank you so much!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!

          -Jason

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Jason.

            Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

            Comment

            Working...