Blerta Blerta
Blerta Blerta

Reputation: 35

Issue with bcc headers sending email

I have this code which is supposed to permit me to send an email to multiple addresses, but, the issue is, it doesn't send them to multiple Bcc...

Here is the code:

$emailbcc=$_POST['emailbcc'];
$sub=$_POST['subject'];
$msg=$_POST['message'];
$emailbcc1= implode("," , $emailbcc);
if($emailbcc!=''){

// multiple recipients
$to = 'address';

// subject
$subject = $sub;

// message
$message = $msg;

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: Up!<address>' . "\r\n";
$headers .= 'Bcc: '.$emailbcc1.'' . "\r\n";


// Mail it
mail($to, $subject, $message, $headers);

$emailbcc1 are some e-mails, i get them using checkboxes... What is wrong with this? Thanks..

Upvotes: 0

Views: 124

Answers (2)

Mihai Iorga
Mihai Iorga

Reputation: 39724

You have to make them emails:

$emailbcc1 = implode(">, <" , $emailbcc);
$emailbcc1 = '<'.$emailbcc1.'>';

Upvotes: 2

Robin
Robin

Reputation: 8518

Make sure that these mail addresses are seperated with a ,!

For example, when you have an array with addresses:

$addresses = array('[email protected]', '[email protected]');

You can set the header in this way:

$headers .= 'BCC: ' + implode(',', $addresses) + '\r\n'; 

Upvotes: 1

Related Questions