-6

I am sending an email using PHP but all the emails are going to the spam folder. Please tell me where I am making a mistake.

<?
    $name=$_POST['name'];
    $email=$_POST['email'];
    $phone=$_POST['phone'];
    $message=$_POST['message'];
    $ToEmail = "me@example.com";
    $ToSubject = "Message from your site";
    $EmailBody = "Name: $name\n 
        Email: $email\n
        Phone: $phone\n
        Message: $message\n";
    $Message = $EmailBody;
    $headers .= "Content-type: text; charset=iso-8859-1\r\n";
    $headers .= "From:".$name." / ".$email."\r\n";
    mail($ToEmail,$ToSubject,$Message, $headers);
    header("location: thankyou.php");
?>
corn on the cob
  • 2,093
  • 3
  • 18
  • 29

1 Answers1

2

Long story short, if the recipient's server put your mail into the spam box, your program is working all right and there is nothing you can do.

Longer Story: Nowadays most mailing servers will check that the email is from a server that actually holds the domain corresponding to the email. Suppose you are sending with account abc@gmail.com, the server of the recipient's email checks if the server from which this mail comes is gmail.com. This is done by checking the SPF record .

phoeagon
  • 2,080
  • 17
  • 20