HTML表单数据通过PHP

时间:2011-12-01 23:30:32

标签: php html forms email

我对PHP脚本完全不熟悉,并将以下代码放在一起,但我希望收到的电子邮件显示它是从HTML表单中的电子邮件字段发送的,而不是当前的“The Tranquility Zone Website [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 = "jenny@tranquilityzone.co.uk";
$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);
?>

3 个答案:

答案 0 :(得分:1)

将您的代码更改为:

<?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 = "jenny@tranquilityzone.co.uk";
    $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);
?>

答案 1 :(得分:0)

您的第二个邮件发送者(mailherders)变量看起来有误导

试试这个:

$headers = 'From: '.$email_from."\r\n".
            'Reply-To: '.$email_from."\r\n" .

$mailheaders = "From: The Tranquility Zone Website <www.tranquilityzone.co.uk>\n";
$mailheaders .= "Reply-to: $_POST[sender_email]\n";

我的免责声明:我不宽恕这种类型的活动,因为当你从真正的发件人以外的人那里收到电子邮件时,它看起来很阴暗。是的,你可能被列入黑名单。

答案 2 :(得分:0)

$mailheaders = "From: $_POST[sender_email]\n";
$mailheaders .= "Reply-to: $_POST[sender_email]\n";

$mailheaders = "From: $_POST[email]\n";