amdilley
amdilley

Reputation: 103

php mail() keeps returning false. Coding issue or hosting issue

I have the following .php file:

<?php

$to = "[email protected]";
$from = $_POST["from"];
$subject = $_POST["subj"];
$message = $_POST["body"];
$headers = "From: ".$from.
     " X-Mailer: php";

if(mail($to, $subject, $message, $headers)){
  header("Location: resume.html");
} else{
   echo("<p>".$to." ".$from." ".$subject." ".$message." ".$headers."</p>");
}

?>

Every time it's called upon, it returns false. Any ideas?

Upvotes: 0

Views: 180

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324600

Your headers are incorrectly formatted. You must have \r\n between them, not a space as you appear to have here.

$headers = "From: ".$from."\r\n"
          ."X-Mailer: php";

Upvotes: 3

Related Questions