问题
I have a form that populates a PHP mail to be sent to our clients, I want to BCC most of the clients due to privacy. I have the following code
$to = "******@e-track.co.za"; //To recipients
$email_from = '*****@etrackbureau.co.za';//<== update the email address
$email_subject = "New Overdue Loaded";
$email_body = "A new High Risk Client has been loaded by $name $company.\n".
"\n Client Name: $driver_name $driver_surname\n
\n Client ID or Passport Number: $driver_id\n
\n Nationality: $driver_nationality\n
\n Reason for Loading Client: $type\n
\n Notes: $notes\n
".
$headers = "From: $email_from \r\n";
$headers = "Bcc: ******@e-track.co.za;*****@e-track.co.za;******@e-track.co.za\r\n";
//$headers = "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
I have added the BCC as a $headers but once I add this it doesn't send mails at all when I remove it I get the mail to the $to recipient.
I have tried spacing between the BCC mails as well. I have replaced the mail names with **** for spamming reasons
回答1:
You should concatenate
$headers
Example :
$headers = "From: *****@etrackbureau.co.za\r\nX-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n"; #Define MIME Version
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; #Set content type
$headers .= "Bcc: $EmailListHere\r\n"; #Your BCC Mail List
回答2:
You need to concatenate the header strings. Replace 'header =' by 'header .=' in your code
回答3:
// Additional headers
$headers[] = 'To: Mary <mary@example.com>, Kelly <kelly@example.com>';
$headers[] = 'From: Birthday Reminder <birthday@example.com>';
$headers[] = 'Cc: birthdayarchive@example.com';
$headers[] = 'Bcc: birthdaycheck@example.com';
// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));
link
回答4:
if you are using phpMailer you should use
$mail->addBCC('bcc@example.com');
this will do the trick and where u r using
$headers = "Bcc: ******@e-track.co.za;*****@e-track.co.za;******@e-track.co.za\r\n";
concatenate it dont use = as it will over write the previous $headers
variable
来源:https://stackoverflow.com/questions/43181025/php-mail-adding-bcc