Jump to content

HTML email via mail()


vassili

Recommended Posts

i've looked everywhere online, and every guide seems to tell you how to set it up but not really tell you how the execution is nailed down.

 

so i have a whole bunch of variables from a form via post.  one variable, $order is a large querystring of HTML.  it looks like this.

 

<table align=\"center\" cellpadding=\"0\" border=\"0\"><tr><td><form action=\"cart.php?action=update\" method=\"post\" id=\"cart\"><table align=\"center\" cellpadding=\"10\" width=\"820\" border=\"0\"><tr><td style=\"border:1px solid #999;\"><a href=\"cart.php?action=delete&id=CSFT03CHI\" class=\"r\">Remove</a></td><td width=\"400\" style=\"border:1px solid #999;\">Men\'s 1/4 Zip Half Sleeve Pullover (albatross) in CHARCOAL/IVORY</td><td style=\"border:1px solid #999;\">$18.00</td><td width=\"50\" style=\"border:1px solid #999;\"><input type=\"text\" name=\"qtyCSFT03CHI\" value=\"11\" size=\"3\" maxlength=\"3\" /></td><td style=\"border:1px solid #999;\">$198.00</td></tr></table><p align=\"right\">Subtotal: <strong>$198.00</strong></p><div align=\"right\"><button type=\"submit\" id=\"mysubmit\">Update cart</button></div><p align=\"right\"><a href=\"memberindex.php\" >Back to Shopping...</a></p>
</form></td></tr></table>

 

the rest are simple strings to ID the sender.  my submit code looks like this.

 

<?php

if(isset($_POST['submit'])) { 
$to = "xxx@gmail.com"; 

$name_field = $_POST['name']; 
$email_field = $_POST['email']; 
$message = $_POST['Comment']; 
$order = $_POST['order']; 
$subject = "New Order From $name_field";
$headers = "From: $name_field <order@xxx> \r\n";
  
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message \n $order"; 
  
echo "Data has been submitted to $to!"; 
mail($to, $subject, $body, $headers); 
} else { 
echo "error: mail not delivered"; 
} 
?>

 

how do i format this so everything in $body shows up as html correctly in the email?  now i know $order doesn't pass the validation right now, but all that needs to work is for me to see the the order...i wasn't thinking ahead when i added the function that spits out the $order querystring and now it's too late to change it.

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.