Send a html email in php

ApocDen

for this to work you need to add some text boxes and name them accordingly, make sure when you add a text box add

$_POST["new_text field"] = $new_text field;

etc etc. html coding can be used within the html tags only.

206 Views
About the Author
<?php
$_POST["name"] = $name;
$_POST["email"] =  $email;
nl2br($_POST["comment"])=  $comment;

$to = "daniweb@daniweb.com";
$from = "".$_POST["email"]."";
$subject = "Code Snipplet for daniweb ";

$message = "<html>
   <body background=\"#4B4B4B\">
   <h1>Code Snipplet for daniweb</h1>

   Hello daniweb  , <br>

    <center>
Name: $name <br>
Email: $email <br>
Comment: $comment <br>
    </center>
  </body>
</html>";
   
    $headers  = "From: Site contact form <daniweb@daniweb.com>\r\n";
    $headers .= "Content-type: text/html\r\n";

	mail($to, $subject, $message, $headers) or die ("Failure");
?>
metalix 0 Posting Whiz in Training

You should also add the smtp info so it doesn't end up in the users spam folder.
also some email programs will display html coding rather than processing it if it doesn't use something like smtp :) :)

SMTP == send mail transfer protocol :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.