将表单数据发送到我的电子邮件地址和用户输入的地址

时间:2013-09-08 12:06:47

标签: php forms email

嗨我一年前问过这个问题,但是无法解决这个问题,现在我又要去了。

链接到原始问题:

Send email to address from form input

我需要将表单数据从我的表单发送到指定地址'diysoakwells@hotmail.com',并从表单字段发送电子邮件地址,该地址分配了变量$ emaile。因为它是电子邮件到达diysoakwells@hotmail.com而不是变量地址($ emaile)。我无法理解为什么,但它肯定会收集表单数据,因为当我在diysoakwells@hotmail.com收到它时,它已包含在电子邮件中的所有详细信息。我基本上想要发送给用户以及我自己的订单副本。

<?php
include_once("wsp_captcha.php");

if(WSP_CheckImageCode() != "OK") {
header('location:/form-rejected.php');
die();
}

$subject = 'Order Inquiry';
$jcitems = " <p><b>ORDER:</b></p><p> " . $_POST['jcitems']."<p/>" . "<p><b>Total:</b> $" . $_POST['jctotal']."</p>";
$time = date ("h:i A"); 
$date = date ("l, F jS, Y");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: inquiry@DIYSoakwells.com' . "\r\n" .
'Reply-To: noreply@diysoakwells.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$name = $_POST['name'];
$phone = $_POST['phone'];
$emaile = $_POST['emaile'];
$textbox = $_POST['textbox'];
$to = "diysoakwells@hotmail.com,$emaile";
$text = "<html><body><p>This form was submitted on Your Web Site on \n $date at\n $time</p><p><b>Message:</b>\n$textbox</p><p><b>Customers Email Address:</b> $emaile</p><p><b>Customers Name:</b> $name </p><p><b>Customers Phone Number:</b> $phone </p></html></body>";
$body = $text . $jcitems;
mail($to, $subject, $body, $headers);
Header('Location: ../form-accepted.php');
?>    

请帮助,如果可以,我将在接下来的几天内对此进行监控。开放给建议/解释!!!

1 个答案:

答案 0 :(得分:0)

$to = "diysoakwells@hotmail.com;" . filter_var($emaile, FILTER_VALIDATE_EMAIL);

您可能还想尝试这个....

$to = "diysoakwells@hotmail.com;<" . filter_var($emaile, FILTER_VALIDATE_EMAIL) . ">";