0

I am new to using php and I bought a website template with an integrated PHP contact form. When I receive email from customers and click to answer their question, it does not automatically use their email address to reply.

I know there is a "reply-to" that I can use in my code to make sure it will be using the customer address when clicking reply on my mail client. I just don't know how to use it.

Here is my code:

<?php 
$to = 'info@webmaster.ca'; // Put in your email address here
$subject  = "Formulaire de contact"; // The default subject. Will appear by default in all messages. Change this if you want.

// User info (DO NOT EDIT!)
$fname = stripslashes($_REQUEST['fname']); // sender's name
$email = stripslashes($_REQUEST['email']); // sender's email

$subject = stripslashes($_REQUEST['subject']);
$message = stripslashes($_REQUEST['message']); 


// The message you will receive in your mailbox
// Each parts are commented to help you understand what it does exaclty.
// YOU DON'T NEED TO EDIT IT BELOW BUT IF YOU DO, DO IT WITH CAUTION!
$msg .= "Nom: ".$fname."\r\n\n";  // add sender's name to the message
$msg .= "Courriel: ".$email."\r\n\n";  // add sender's email to the message

$msg .= "Sujet: ".$subject."\r\n\n";  // add sender's name to the message
$msg .= "-----Commentaire------: ".$message."\r\n\n";  // add sender's email to the message
$msg .= "\r\n\n"; 

$mail = @mail($to, $subject, $msg, "De:".$email);  // This command sends the e-mail to the e-mail address contained in the $to variable

if($mail) {
    header("Location:index.php");   
} else {
    echo 'Envoi du message a échoué!';   //This is the message that will be shown when an error occured: the message was not send
}

?>

1 Answers1

0

Just include the From or Reply-To header in your fourth parameter of mail().

Edit:

What you have now "De:".$email as stated in comments, is French for "From". Syntax is language specific and must be in English.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Niek van der Steen
  • 1,413
  • 11
  • 33