php php邮件功能:只发送邮件到密件抄送

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4117091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:01:22  来源:igfitidea点击:

php mail function: Sending mails to BCC only

php

提问by Volatil3

the first param of php mail function is TO. Is there anyway to skip this parameter and use only CC/BCC to send bulk mails?

php邮件函数的第一个参数是TO。无论如何要跳过此参数并仅使用 CC/BCC 发送批量邮件?

Thanks

谢谢

回答by Gumbo

An email message does not require a Toheader field. So you could pass nullor a blank string for the toparameter, set up your own header containing the BCCheader field and provide it with the fourth parameter additional_headersof mail:

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

$headerFields = array(
    'BCC: [email protected], [email protected], [email protected]'
);
mail(null, $subject, $message, implode("\r\n", $headerFields));

回答by Sarfraz

You can specify fourth headers parameter for that like this:

您可以像这样指定第四个 headers 参数:

    $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 protected]"\n";
    $xheaders .= "Cc:[email protected]\n";

    //.......

    mail($to, $subject, $msg, $xheaders);

In the $tofield you can specify your email or whatever you like.

在该$to字段中,您可以指定您的电子邮件或任何您喜欢的内容。

Notethat you can also specify multiple email addresses by separating them with a comma although I am not sure about exact number of email you can specify this way.

请注意,您还可以通过用逗号分隔多个电子邮件地址来指定多个电子邮件地址,尽管我不确定您可以通过这种方式指定的确切电子邮件数量。

回答by Fahad Sadah

You can put your own email address, or another dummy, in the Toheader, and put all the recipient addresses in Bcc.

您可以将自己的电子邮件地址或其他虚拟地址To放在标题中,并将所有收件人地址放在Bcc.