PDA

View Full Version : email.php question



metafiction
October 31st, 2006, 02:35 PM
Below is the php I wriote. the mail gets sent fine, but all the fields (name, phone, subject and comments) get jumbled into one long string in the body of the email. Thanks for looking:

$sendTo = "info@miramichiphoto.com";
$subject = "Contact Form MP";

$headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];

$message = $_POST["comments"];

$body = "From: $name_field\n E-Mail: $email_field\n Phone: $phone_field\n Subject: $subject_field\n Message:\n $comments_field";

mail($sendTo, $subject, $headers, $message, $body);

buildakicker
October 31st, 2006, 02:58 PM
TRY THIS:


$body = "From: " . $name_field . "<br />" . "E-Mail: " . $email_field . "<br />" . "Phone: " . $phone_field . "<br />" . "Subject: " . $subject_field . "<br />" . "Message: " . $comments_field;

hl
October 31st, 2006, 05:21 PM
^ That'll require you to edit the mime type as well.

metafiction
October 31st, 2006, 07:38 PM
OK. I got the form to send. There is a text input field on the form with the var "phone", and every time I try to add to the code that will include that field in the body of the email, the whole thing goes for a ****. here is what I have so far:

$sendTo = "info@miramichiphoto.com";
$subject = $_POST["subject"];

$headers = "From: " . $_POST["name"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];
$message = $_POST["comments"];

mail($sendTo, $subject, $message, $headers);

raz
November 1st, 2006, 08:00 AM
$sendTo = "info@miramichiphoto.com";
$subject = $_POST["subject"];

$headers = "From: " . $_POST["name"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];
$message = "Phone: " . $_POST["phone"] . "\n\n" . $_POST["comments"];

mail($sendTo, $subject, $message, $headers);