php mail功能:仅向BCC发送邮件

Vol*_*il3 8 php

php邮件功能的第一个参数是TO.是否有跳过此参数并仅使用CC/BCC发送批量邮件?

谢谢

Gum*_*mbo 14

一个电子邮件不需要头域.所以,你可以通过null或者一个空字符串为参数,设置一个包含自己的头BCC报头字段,并为它提供了第四个参数additional_headersmail:

$headerFields = array(
    'BCC: user1@example.com, user2@example.com, user3@example.com'
);
mail(null, $subject, $message, implode("\r\n", $headerFields));
Run Code Online (Sandbox Code Playgroud)


Sar*_*raz 13

您可以为此指定第四个头参数:

    $xheaders = "";
    $xheaders .= "From: <$from>\n";
    $xheaders .= "X-Sender: <$from>\n";
    $xheaders .= "X-Mailer: PHP\n"; // mailer
    $xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
    $xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
    $xheaders .= "Bcc:email@example.com"\n";
    $xheaders .= "Cc:email2@example.com\n";

    //.......

    mail($to, $subject, $msg, $xheaders);
Run Code Online (Sandbox Code Playgroud)

$to现场,您可以指定您的电子邮件或任何您喜欢的.

请注意,您也可以使用逗号分隔多个电子邮件地址,但我不确定您可以通过这种方式指定的确切电子邮件数量.