HTML email php

Discussion in 'PHP' started by designaire, Mar 5, 2008.

  1. #1
    I'm having trouble with sending an email through a form and formatting it with html. It's just a simple form. I get the email but the tags are in the email instead of it being formatted. Thanks....

    <?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>
    ';
    $fromaddress ='From: ';
    $headers='MIME-Version: 1.0'."\r\n";
    $headers.='Content-Type: text/html; charset=iso-8859-1'."\r\n";
    mail($toaddress, $subject, $message, $fromaddress, $headers);
    ?>
     
    designaire, Mar 5, 2008 IP
  2. designaire

    designaire Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I just figured it out, I had 5 parameters in the mail function instead of 4
    <?php
    $name=$_POST['name'];
    $work=$_POST['work'];
    $toaddress = 'xxx@xx.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@xx.com>". "\r\n";
    mail($toaddress, $subject, $message, $headers);
    ?>
     
    designaire, Mar 5, 2008 IP