繁体   English   中英

为什么不隐藏通过php邮件发送的密件抄送电子邮件

[英]why bcc emails sent via php mail are not hidden

我正在尝试通过密件抄送发送电子邮件,但我希望它们被隐藏,但事实并非如此。 也许我的代码不正确?

// grab all emails from txt file
$myfile = fopen("database-email.txt", "r") or die("Unable to open file!");
$allEmails = fread($myfile,filesize("database-email.txt"));
fclose($myfile);

$afzender = "noreply@wisselslag.nl";

$to = 'pj.maessen41@live.nl';

$subject = 'Nieuwsbrief de Wisselslag';

$headers = "From: " . $afzender . "\r\n";   
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Bcc: " . $allEmails  . "\r\n";

if (mail($to, $subject, $message, $headers)) {
  echo 'Bericht is verstuurd!';
} else {
  echo 'There was a problem sending the email.';
}

所以我有一个database-email.txt文件,其中存储了所有电子邮件,像这样彼此分隔逗号:

joey.tims@gmail.com,
j.maessen@online.nl,
john.doe@live.nl,
diana.johnson@hotmail.com,

发送到我的Gmail帐户时,我可以看到此信息:

在此处输入图片说明

我怎么可能看到电子邮件也发送到哪里?

电子邮件列表不应包含换行符。

使其一行:

$allEmails = str_replace(array("\n","\r"), '', $allEmails);

// joey.tims@gmail.com, j.maessen@online.nl, john.doe@live.nl, diana.johnson@hotmail.com

如我的评论中所述,任何收件人列表都不应包含换行符。

我会将文件格式更改为一行

joey.tims@gmail.com,j.maessen@online.nl,john.doe@live.nl,diana.johnson@hotmail.com

我还将使用file_get_contents()代替fopen / fread


或者,将您的电子邮件地址存储在每行中,但不要使用逗号,例如

joey.tims@gmail.com
j.maessen@online.nl
john.doe@live.nl
diana.johnson@hotmail.com

并使用file()implode()

$allEmails = implode(',' file(__DIR__ . '/database-email.txt',
        FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM