0

Pearを使用したSMTP認証を使用したお問い合わせフォームがあります。フォームに記入された方にも確認メールを送りたいと思います。

これを実現するには、PHPに何を追加する必要がありますか

<?php
        error_reporting(E_ALL);
        ini_set('display_errors', True);

        set_include_path('******');

        require_once "Mail.php";

// Set the email variables from the form here:

    $name = $_POST['name']; // Pass the Name value to the $Name variable
    $number = $_POST['number'];
    $email = $_POST['email']; // Pass the Email value to the $Email variable
    $enquiry = $_POST['enquiry'];
    $comment = $_POST['message']; // Pass the Comment value to the $Comment variable

 $from = $email;
 $to = "Enquiries <enquiries@brisbanediveacademy.com.au>";
 $subject = "Enquiry ( $enquiry)";

        $body = "You have received a Web Enquiry. \n
            Name: $name\n
            Contact: $number \n
            Email: $email\n
            Enquiry Type: $enquiry \n
            Comments: $comment";

 $host = "******.com.au";
 $username = "*****.com.au";
 $password = "******";

 $headers = array('From' => $from,
                  'To' => $to,
                  'Subject' => $subject);
 $smtp = Mail::factory('smtp',
                       array('host' => $host,
                            'auth' => true,
                            'username' => $username,
                            'password' => $password));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
     echo("<p>" . $mail->getMessage() . "</p>");
 } else {
     echo("<p>Message successfully sent! We will be in contact with you shortly!</p>");
 }
 ?>

ありがとう、

4

2 に答える 2

2

ヘッダー配列で CC を使用できます

 'Cc' => 'Sendername <$from>',

または前夜

'Bcc' => 'Sendername <$from>',
于 2012-10-19T23:22:37.150 に答える
0

Ivan のソリューションは、受信したメールと同じメールを受信して​​もらいたい場合に適しています。

しかし、最善の方法は、彼に別のメールを送信することです。

2 つ生成します。1回はあなたに、もう1回は彼に。

共通部分に別の変数を使用させたい場合は、メッセージに追加または先頭に追加します。

于 2012-10-19T23:35:15.463 に答える