我有以下php邮件文件:
<?php $name = $_POST['name'];
$email = $_POST['email'];
$choice = $_POST['choice'];$num = $_POST['num'];
$choice1 = $_POST['choice1'];$num1 = $_POST['num1'];
$phone= $_POST['phone'];
$town= $_POST['town'];
$formcontent="
Name: $name \n
Number: $phone \n
Choice: $choice Amount:$num
Choice: $choice1 Amount:$num1
Town: $town \n
Email: $email" ;
$recipient = "info@domain.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";?>
我可以将$ email添加到收件人吗?我想将表单中输入的电子邮件添加到接收电子邮件的收件人中。 (info@domain.com和表格中输入的电子邮件($ email = $ _POST ['email'];)将收到该电子邮件。
答案 0 :(得分:2)
您可以使用逗号分隔多个电子邮件地址$recipient
。试试这个。
$recipient = "info@domain.com, $email";
修改强>
以下是整个事情。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$choice = $_POST['choice']; $num = $_POST['num'];
$choice1 = $_POST['choice1']; $num1 = $_POST['num1'];
$phone= $_POST['phone'];
$town= $_POST['town'];
$formcontent = "
Name: $name \n
Number: $phone \n
Choice: $choice Amount:$num
Choice: $choice1 Amount:$num1
Town: $town \n
Email: $email";
$recipient = "info@domain.com, $email";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank you";
?>