Below I attach ta PHP script used to send data from a web form by email.
I get the "ok.htm" page all right, at the end, but for some reason the email is not sent/received. (Actual email is different from the one shown.) I would like to verify if there is a syntax error or other problem before I contact the server people. Thanks in advance.
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['
EmailFrom'
]));
$EmailTo = "my@email.com";
$Subject = "job enquiry";
$Name = Trim(stripslashes($_POST['
Name']));
$Company = Trim(stripslashes($_POST['
Company'])
);
$City = Trim(stripslashes($_POST['
City']));
$Country = Trim(stripslashes($_POST['
Country'])
);
$Telephone = Trim(stripslashes($_POST['
Telephone'
]));
$Email = Trim(stripslashes($_POST['
Email']));
$YourMessage = Trim(stripslashes($_POST['
YourMessag
e']));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\
">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "YourMessage: ";
$Body .= $YourMessage;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"
;
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\
">";
}
?>
Start Free Trial