bcc标题发送电子邮件的问题

时间:2012-10-05 10:39:10

标签: php

我有这个代码应该允许我向多个地址发送电子邮件,但问题是,它不会将它们发送到多个密件抄送...

以下是代码:

$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是一些电子邮件,我使用复选框... 这有什么问题? 感谢..

2 个答案:

答案 0 :(得分:2)

您必须向他们发送电子邮件:

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

答案 1 :(得分:1)

确保这些电子邮件地址以,分隔!

例如,当您有一个包含地址的数组时:

$addresses = array('example1@example.com', 'example2@example.com');

您可以这样设置标题:

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