Sending a HTML e-mail message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webandwe
    New Member
    • Oct 2006
    • 142

    Sending a HTML e-mail message

    Hi, I tried to get a script or something to send my e-mial in HTML format becasuse I want to add tables to line up certain text.

    How do I get the e-mail to go from plain text to HTML?

    Thanks

    [PHP]
    <?php
    $con = mysql_connect(" ******","****** ","****");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_d b("total", $con);$result = mysql_query("SE LECT * FROM email");while($ row = mysql_fetch_arr ay($result))
    {
    $to = "$row[a1]";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@exa mple.com";
    $headers = "From: $from";
    mail($to,$subje ct,$message,$he aders);
    echo "Mail Sent.";

    }mysql_close($c on);
    ?>

    [/PHP]
  • brettl
    New Member
    • Sep 2007
    • 41

    #2
    You'll have to add the following to your headers variable:
    [CODE=php]
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    [/CODE]

    Then just build your html in your message variable like so:
    [CODE=php]
    $message = '<html><head><t itle>Some Title Here</title></head>';
    $message .= '<body><p>So and so sent you this url';
    $message .= '<a href="http://www.somedomain. com/url.html" title="URL Title">Url Title</a><br/>';
    $message .= 'And a message : <br/>';
    $message .= $mailMessage.'</p></body></html>';
    [/CODE]

    Hope this helps. Let me know.

    Comment

    Working...