I am working on a small project which I was recruited for. It was supposed to be a simple 2 form thing, but i am stuck on the first form. No matter what, I get a "False" returned from the e-mail function, but the e-mail gets sent with all the expected information. How is that possible, and how can I account for it or fix it? Unfortunately, I really do not have any information about the hosting server. I just know it is Linux.
Here is a snippet of my code:
function send_home_quote($email_body, $name){
# Sends an e-mail to the designated recipient(s) containing the form contents
// Assign all needed variable values...
$send_to = "email@domain.com";
$subject = "Subject Line";
// Create the e-mail headers
$email_headers = "MIME-Version: 1.0\r \n";
$email_headers .= "To: $name <$send_to>\r \n";
$email_headers .= "From: Online Form <$send_to>\r \n";
$email_headers .= "Reply-to: " . $name . " <$send_to>\r \n";
$email_headers .= "X-Mailer: PHP Mailer\r \n";
$email_headers .= "Content-Type: text/html; charset=us-ascii\r \n";
# Send mail
if (mail($send_to, $subject, stripslashes($email_body), $email_headers) == true) {
return 1; // The mail function worked
}else{
return 0; // The mail function failed
}
}
I have printed and print_r() all variables, and everything looks fine to me. The if statement at the end will tell the requesting code whether to echo() a failure or a success. I know the $send_to variables are repeated. I have to do that. If that is what you think is causing the error, I will try and do something else. I just will not be retrieving an e-mail from the visitor filling out the form. I should also add that this is an HTML formatted e-mail.