Jump to content

email form html


designaire

Recommended Posts

Hi,

 

I'm trying to format an email sent through a php form with using html to format the message. According to what I've read, I use the following $header code. I tryed to use the following code for the message as a test which is from the php.net website. It doesn't work, however. Can anybody tell me what I'm doing wrong or why it might not be working? It's right off the php.net website.

 

<?php

  //create short variable names

  $toaddress = '[email protected]';

  $subject = 'test';

  $mailcontent = '<html>

<head>

  <title>Birthday Reminders for August</title>

</head>

<body>

  <p>Here are the birthdays upcoming in August!</p>

  <table>

    <tr>

      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>

    </tr>

    <tr>

      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>

    </tr>

    <tr>

      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>

    </tr>

  </table>

</body>

</html>

';

 

  $fromaddress = 'From: [email protected];

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

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

  mail($toaddress, $subject, $mailcontent, $fromaddress, $headers);

?>

Link to comment
https://forums.phpfreaks.com/topic/94380-email-form-html/
Share on other sites

ok if you reciev the email at all then smtp is setup correctly.

 

If you are saying when you get the email you can see all the html tags, then the email is being sent as a plain text.

- Check your headers.

 

 

// 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";

http://uk.php.net/manual/en/function.mail.php

 

from wat i can see there are no problems in the script, try emailing different addresses, try the email without the <html> and <head> and <body> tags, eg:

  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>

 

 

hope this helps,

 

Link to comment
https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483895
Share on other sites

I figured it out, I had 5 parameters instead of 4...it works now.

 

<?php

$name=$_POST['name'];

$work=$_POST['work'];

$toaddress = '[email protected]';

$subject = 'test';

$message ='

<head>

<title>Untitled Document</title>

</head>

<body>

My name is '.$name.' and I do '.$work.' in my feild.

</body>

';

 

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

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

$headers.="From: <xxx@xxxcom>". "\r\n";

mail($toaddress, $subject, $message, $headers);

?>

Link to comment
https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-484175
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.