[FONT="Trebuchet MS"]Hello world.
Hello everyone.
I have a little script here to harness the data posted by the user on the HTML page and send it to the PHP script. The script will then send 1 e-mail to the guest and 1 e-mail to my staff, however, the e-mail that the guest gets has 'example@example.com' in the from field when I want it to have 'Town and Country Hotels'. In other words, it's displaying an e-mail address when I want it to display a name. Below is my code (I have excluded the non-necessary parts for simplicity):
<?php
// Retrieve posted data and turn into local variables
$OUREMAIL = 'Town and Country Hotels <example@example.com>';
$EMAIL = Trim(stripslashes($_POST['EMAIL']));
$NAME = Trim(stripslashes($_POST['NAME']));
$EmailTo = "info@townandcountryhotels.net";
$EmailToWebmaster = "webmaster@townandcountryhotels.net";
$EmailTo2 = $EMAIL;
$Subject = "Town and Country Hotels Online Form Submission";
$Subject2 = '' . $NAME . ', your message has been received!';
// validation
$validationOK=true;
if (Trim($EMAIL)=="") $validationOK=false;
if (Trim($NAME)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// Body of e-mail to staff has been excluded in the forum post
// Body of e-mail to guest
$Body2 .= "";
$Body2 .= "Dear ";
$Body2 .= $NAME;
$Body2 .= ",";
$Body2 .= "\n";
$Body2 .= "\n";
$Body2 .= "Thank you for your message! A representative will be with you shortly, answering all your queries about Amamzintaba Resort. If you require an answer as a matter of urgancy, please call the hotel manager on 0027 824 529 015. Below is a copy of your message:";
$Body2 .= "\n";
$Body2 .= "\n";
$Body2 .= "Name: ";
$Body2 .= $NAME;
$Body2 .= "\n";
$Body2 .= "E-mail address: ";
$Body2 .= $EMAIL;
$Body2 .= "\n";
$Body2 .= "Telephone number (if given): ";
$Body2 .= $TELEPHONE;
$Body2 .= "\n";
$Body2 .= "Topic of question: ";
$Body2 .= $TOPIC;
$Body2 .= "\n";
$Body2 .= "Question: ";
$Body2 .= $QUESTION;
$Body2 .= "\n";
$Body2 .= "\n";
$Body2 .= "----";
$Body2 .= "\n";
$Body2 .= "This message was sent to ";
$Body2 .= $EMAIL;
$Body2 .= " and confirms the receipt of your message submitted via the Town and Country Hotels online contact form. Information submitted through this form is reatined for customer service improvement purposes and will never be rented, sold or distributed to a tertiary party whatsoever. This has been laid out in the privacy policy viewable at http://www.townandcountryhotels.net/legal.php#privacypolicy.";
$Body2 .= "\n";
$Body2 .= "\n";
$Body2 .= "This is an unmonitored mailbox. Replies will be discarded.";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EMAIL>");
$success = mail($EmailToWebmaster, $Subject, $Body, "From: <$EMAIL>");
$success = mail($EmailTo2, $Subject2, $Body2, "From: <$OUREMAIL>");
// Redirect the guest to the success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=msgsent.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
If you visit my site (URL removed) you'll see what I mean when you send a message. All advice is very much appreciated.[FONT="Trebuchet MS"][/FONT][/FONT]