我是使用php的新手,我购买了一个带有集成PHP联系表单的网站模板。当我收到客户的电子邮件并单击以回答他们的问题时,它不会自动使用他们的电子邮件地址进行回复。
我知道可以在我的代码中使用"回复",以确保在我的邮件客户端上单击回复时它将使用客户地址。我只是不知道如何使用它。
这是我的代码:
<?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."rnn"; // add sender's name to the message
$msg .= "Courriel: ".$email."rnn"; // add sender's email to the message
$msg .= "Sujet: ".$subject."rnn"; // add sender's name to the message
$msg .= "-----Commentaire------: ".$message."rnn"; // add sender's email to the message
$msg .= "rnn";
$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
}
?>
只需在mail()
的第四个参数中包含From
或Reply-To
标头即可。
编辑:
如评论中所述,您现在"De:".$email
的是法语中的"来自"。语法是特定于语言的,必须使用英语。