0

to submit a form using email functionality:

$to = "ayush@***.com"; 
$from = $_REQUEST['email']; 
$name = $_REQUEST['name'];
$phone = $_REQUEST['phone'];
$message = $_REQUEST['message'];

$subject = "Form submission";

$message = $name . " " . $phone . " " .$message. " wrote the following:" . "\n\n" . $_REQUEST['message'];

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=isoo-8859-1\r\n";
$headers = "From:" . $from;

i am not able to send email

mail($to,$subject,$message,$headers);

header('Location: thank-you.php');
  • 1
    mail() function is not always sufficient to sending mail in all hosting providers. Try SMTP or PHPMailer. – Bhavin Dec 16 '16 at 13:02
  • And use `$_POST` instead of `$_REQUEST`. Request contains GET, POST and COOKIE, so you won't be sure that the data really comes from the post. – Twinfriends Dec 16 '16 at 13:04

1 Answers1

2

Your last header is broken.

$headers = "From:" . $from;

It requires the dot (concatenate) for it also.

$headers .= "From:" . $from;

Mail is rejected since there is no valid From and is caused by it being broken.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141