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

780

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: <[email protected]>' . "\r\n" .
 'Reply-To: ' . $Email . "\r\n"; <-- This is not working

Please help.

771

Answer

Solution:

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";

People are also looking for solutions to the problem: php - How to cascade 3 dropdown using javascript?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.