i am trying to send emails via Bcc and i was expecting that they were hidden but it seems not. Maybe my code is not correct?
// 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 = "[email protected]";
$to = '[email protected]';
$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.';
}
So i have a database-email.txt
file in which all the emails are stored, comma seperated from each other like this:
[email protected],
[email protected],
[email protected],
[email protected],
When sending to my gmail account, i can see this:
How is this possible that i can see to where the email also is sent to?
The email list should not have new line character.
Make it one line:
$allEmails = str_replace(array("\n","\r"), '', $allEmails);
// [email protected], [email protected], [email protected], [email protected]