tags:

views:

81

answers:

1

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?

A: 

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' . "\r\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  $headers .= 'From:'.$email."\r\n";
  $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."; }
?>
Starx
Beware of email header injection: http://www.damonkohler.com/2008/12/email-injection.html
Ben James
Wow, this is working. Thanks Starx
Starx