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 = 'xxx@xxx.com';

  $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: xxx@xxx.com;

  $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
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
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 = 'xxx@xxx.com';

$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
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.