编辑:
$recipient = $_SESSION['email'];
不起作用,但是
$recipient = "myemail@me.com";
奇迹般有效 .
我有联系表格,但我想使用联系表格向该人发送不同的电子邮件 .
因此,当他们点击订单时需要发送总共2封邮件(订单确认管理,订单确认给买家)
他/她的电子邮件地址存储在$ _SESSION ['email']中,但如果我把它放在收件人字段中,我就无法工作了...
<?
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (!$_POST['currentamount'] && !$_POST['nextamount']) {
$error_msg ="- You have to order atleast one ticket.<br>";
}
if ($_POST['currentamount'] && !$_POST['date1']) {
$error_msg ="- You didn't select a date for the current show<br>";
}
if ($_POST['nextamount'] && !$_POST['date2']) {
$error_msg ="- You didn't select a date the the next show.<br>";
}
if (!empty($error_msg)) {
//Een van de velden werd niet goed ingevuld
echo "<b>Your message can't be send due to the following reason:</b> <br><br>";
echo $error_msg;
echo "<br>Click on <a href='javascript:history.back(1)'>Go back</a> and provide us with the needed information.<br><br>";
} else {
$recipient = "tickets@*******.com"; //Het email adres van de persoon die vragen moet ontvangen.
$subject = "MTP: Ticket Order"; //Subject van de mail.
$header = "From: noreply@*********";
$mail_body = "Contact script werd op " . date("d-m-Y") . " om " . date("H:i") . " uur uitgevoerd.\n";
$mail_body .= "De volgende persoon zou graag kaarten bestellen:\n";
$mail_body .= "Naam: " . $_POST['name2'] . "\n";
$mail_body .= "Met als kaartnummer: " . $_POST['card2'] . "\n\n";
$mail_body .= "For the " . $_POST['currentshow'] . ", ". $_POST['name2'] ." would like ". $_POST['currentamount'] ." tickets on date: " . $_POST['date1'] . ".\n";
$mail_body .= "For the " . $_POST['nextshow'] . ", ". $_POST['name2'] ." would like ". $_POST['nextamount'] ." tickets on date: " . $_POST['date2'] . ".\n";
$mail_body .= "This gives us a total of : " . $_POST['total2'] . " EUR\n";
$mail_body .= "\n\n -- ****** --";
mail($recipient, $subject, $mail_body, $header);
print "<b>IMPORTANT!</b>";
print "<br><br>Thank you for your reservation.";
print "<br><br>We are looking forward to meet you.";
}
} else {
?>
2 回答
您应该设置收件人变量,如下所示:
然后像你一样邮寄它
编辑:也许您可以尝试将
$_SESSION['email']
存储在变量$recipient
中作为字符串 . 因此,在将电子邮件存储在收件人变量中之前,将其转换为字符串,它可以工作 .实际上,您可以使用包含2个电子邮件调用的操作页面,一个用于向管理员发送电子邮件,另一个用于向客户发送电子邮件 . 你可以尝试这样的事情:
您可以从同一个action.php页面发送多封电子邮件