我是PHP脚本的新手,并整理了以下代码,但我希望收到的电子邮件显示来自HTML表单的电子邮件字段,而不是当前的“The Tranquility Zone网站[www.tranquilityzone.co .uk @ linweb.ahost.me]”。请您告知我应该更改的内容。非常感谢。
<?
$msg .= "Name:\t $_POST[name]\n";
$msg .= "E-mail:\t $_POST[email]\n";
$msg .= "Telephone:\t $_POST[telephone]\n";
$msg .= "Subject:\t $_POST[subject]\n";
$msg .= "Message:\t $_POST[message]\n";
$to = "[email protected]";
$subject = "Website feedback message";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
$mailheaders = "From: The Tranquility Zone Website <www.tranquilityzone.co.uk>\n";
$mailherders .= "Reply to: $_POST[sender_email]\n";
header( "Location: http://www.tranquilityzone.co.uk/thank_you.html" );
@mail ($to, $subject, $msg, $mailheaders);
?>
最佳答案
将您的代码更改为此:
<?php
$msg .= "Name:\t ".$_POST['name']."\n";
$msg .= "E-mail:\t ".$_POST['email']."\n";
$msg .= "Telephone:\t ".$_POST['telephone']."\n";
$msg .= "Subject:\t ".$_POST['subject']."\n";
$msg .= "Message:\t ".$_POST['message']."\n";
$to = "[email protected]";
$subject = "Website feedback message";
$headers = 'From: '.$_POST['email']."\r\n".'Reply-To: '.$_POST['email']."\r\n" .
$mailheaders = "From: ".$_POST['email']."\n";
$mailheaders .= "Reply to: ".$_POST['email']."\n";
header( "Location: http://www.tranquilityzone.co.uk/thank_you.html" );
@mail ($to, $subject, $msg, $mailheaders);
?>