Php 如何将我的网站联系人表单发送给多个收件人(电子邮件)

Php 如何将我的网站联系人表单发送给多个收件人(电子邮件),php,html,Php,Html,如何使我的web联系人表单向多封电子邮件发送请求,而每封电子邮件都不会看到其他电子邮件接收到来自web联系人表单的相同请求。我的代码工作正常,但仅将联系人表单中的请求发送到一个电子邮件地址,如何将其发送到多个电子邮件这是我的代码,如下所示: <?php $name = $_POST['name']; // form field $email = $_POST['email']; // form field $message = $_POST['mess

如何使我的web联系人表单向多封电子邮件发送请求,而每封电子邮件都不会看到其他电子邮件接收到来自web联系人表单的相同请求。我的代码工作正常,但仅将联系人表单中的请求发送到一个电子邮件地址,如何将其发送到多个电子邮件这是我的代码,如下所示:

    <?php
     $name = $_POST['name']; // form field
     $email = $_POST['email']; // form field
     $message = $_POST['message']; // form field

     if ($_POST['submit']){
     $from = "Contact us<info@xxxxxx>"; //enter your email address
     $to = "xxxxxx@outlook.com"; //enter the email address of the contact your sending to
     $subject = "you have 6 pending mail"; // subject of your email
     $bcc = "";
    $headers = array ('From' => $from,'To' => $to, 'Subject' => $subject, 'headers' => $headers);

    $text = ''; // text versions of email.
    $html = "<html><body>

    Name: $name <br> Email: $email <br>Message: $message <br>

    </body></html>"; // html versions of email.

    $crlf = "\n";

    $mime = new Mail_mime($crlf);
    $mime->setTXTBody($text);
    $mime->setHTMLBody($html);

    //do not ever try to call these lines in reverse order
    $body = $mime->get();
    $headers = $mime->headers($headers);

     $host = "localhost"; // all scripts must use localhost
     $username = "xxxxxxx"; //  your email address (same as webmail username)
     $password = "xxxxxx"; // your password (same as webmail password)

    $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!</p>");
    // header("Location: http://www.example.com/");
    }
      }
     ?>

     <form action="qservers_mail.php" method="post">
    <table border="0" style="background:#ececec" cellspacing="5">
    <tr align="left"><td>Name</td><td><input type="text" size="30" name="name"></td></tr>
    <tr align="left"><td>Email address</td><td><input type="text" size="30" name="email"></td></tr>
    <tr align="left"><td valign="top">Comments</td><td><textarea name="message" rows="6" cols="30"></textarea></td></tr>
    <tr align="left"><td>&nbsp;</td><td><input type="submit" value="Send" name='submit'></td></tr>
    </table>
    </form>

名称
电子邮件地址
评论

只需将它们用逗号隔开即可


$to=”first@mail.ru, second@mail.ru";

尝试一下,但仍会显示收到它的其他人的电子邮件