0

Can anyone inform me about how to correctly send mail from a contact form so it will be received in my inbox instead of the funk folder?

<?php
$EmailFrom = "myhost@email.nl";
$EmailTo = "myemail@address.com";
$Subject = "Mail via mydomain.nl";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text

$Body = "";
$Body .= "Naam: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Bericht: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

This is the code i've got so far. It 'trims' the input from the HTML, throws this in the $body variable.

How do i make the mail look safe to my inbox? $headers? :)

MANOJ GOPI
  • 1,279
  • 10
  • 31
Bokdem
  • 436
  • 3
  • 9
  • Junk mail filtering depends on the contents and where the mail is sent from. It has nothing to do with how you write the script. – Barmar Jan 31 '15 at 10:57
  • @Barmar Does this depend if the $EmailFrom variable matches my domain's email server? – Bokdem Jan 31 '15 at 11:05
  • It could, depending on the SPF DNS entries of the domain in `$EmailFrom`. – Barmar Jan 31 '15 at 11:07

0 Answers0