Ranjith bhaskaran Ranjith bhaskaran - 6 months ago 10
PHP Question

I want to take the email from the following value as Reply to address in my message

My Javascript

var dataString = 'Name='+ name + '&Email=' + email + '&Phone=' + phone + '&Comment=' + comment;



$.ajax({
type: "POST",
url: "mail2.php",

data: dataString,



PHP mail script (mail2.php):

$headers .= 'From: ' . "\r\n" .
'Reply-To: ' . $Email . "\r\n"; <-- This is not working

Please help.

Answer

You are passing data using post method in ajax. so you will get your data in post in mail2.php file.

PHP mail script (mail2.php):

Wrong

$headers .= 'From: ' . "\r\n" . 'Reply-To: ' . $Email . "\r\n"; <-- This is not working

Correct code

$headers .= 'From: ' . "\r\n" . 'Reply-To: ' . $_POST['Email'] . "\r\n";