2

次の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'];) に入力されたメールアドレス) にメールが届きます。

4

1 に答える 1

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";

?>
于 2013-01-09T18:01:23.507 に答える