June 8, 2010

Why is this mail going straight to SPAM box?

Question by Starx

I am using the following script to send mail

<?
extract($_POST);
$subject = "Feedback from ".$name." (".$email.", Ph: ".$phone.")";
$mail = @mail($send,$subject,$content);
if($mail) { echo "Your feedback has been sent"; }
else { echo "We are sorry for the inconvienience, but we could not send your feedback now."; }
?>

But this is always ending up in the spam Folder. Why?

Answer by Starx

You have to use headers while you send mail, to prove that the mail arrives from a genuine source and not a bot.

Try this!

<?
  extract($_POST);
  $subject = "Feedback from ".$name." (".$email.", Ph: ".$phone.")";
  $headers  = 'MIME-Version: 1.0' . "rn";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  $headers .= 'From:'.$email."rn";
  $headers .= 'Reply-To: '.$email;
  $mail = @mail($feedback,$subject,$content,$headers);
  if($mail) { echo "Your feedback is send"; }
  else { echo "We are sorry for the inconvienience, but we could not send your feedback now."; }
?>

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!