NogDog wrote:I tried a few different email addresses with the function and it seemed to be OK. Perhaps you can copy-and-paste your code here to see if there's some logic error in the way it's implemented?
Personally, since validating the format does nothing to verify that the user entered a n actual, valid email address, I'm more of a fan of the "enter it twice" method, and just making sure there is no white-space in it (mainly to prevent email header injection).
I decided that script was WAY over my head. But I have found another sample script and everything works except, the body of the email does not show up. I get the email, but it's empty. And I have no idea why it doesn't work. 😕
<?php
// Grab the form vars
$email = (isset($_POST['email'])) ? $_POST['email'] : '' ;
$message = (isset($_POST['message'])) ? $_POST['message'] : '' ;
$name = (isset($_POST['name'])) ? $_POST['name'] : '' ;
$address = (isset($_POST['address'])) ? $_POST['address'] : '' ;
$city = (isset($_POST['city'])) ? $_POST['city'] : '' ;
$state = (isset($_POST['state'])) ? $_POST['state'] : '' ;
$zip = (isset($_POST['zip'])) ? $_POST['zip'] : '' ;
$phone = (isset($_POST['phone'])) ? $_POST['phone'] : '' ;
// Check for email injection
if (has_emailheaders($email)) {
die("Possible email injection occuring");
}
// prepare email body text
$Body = "";
$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "City: ";
$Body .= $city;
$Body .= "\n";
$Body .= "State: ";
$Body .= $state;
$Body .= "\n";
$Body .= "Zip: ";
$Body .= $zip;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $phone;
$Body .= "\n";
// mail(to,subject,message,headers,parameters)
mail("toEMAIL@anywhere.com","Request for information: ",$body, "From: $email");
function has_emailheaders($text) {
return preg_match("/(%0A|%0D|\n+|\r+)(content-type😐to😐cc😐bcc🙂/i", $text);
}
?>