向多个收件人发送电子邮件时看不到其他用户地址

时间:2013-11-27 07:10:37

标签: php email

您好朋友我通过管理面板向他们的电子邮件地址发送注册用户激活链接和代码,并且工作正常的用户可以获得提供链接和代码。

但问题是users can see other recipients email address In To:我希望用户看不到其他收件人的电子邮件地址?

这里是我的代码

<?php 
//creating activation code
$alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$length = 11;
for($i=0; $i<$length; $i++){
$ran = rand(0, strlen($alpha)-1);
$new_key .= substr($alpha, $ran, 1);
}   


$activation = 'activation.php?email='.urlencode($_POST['email1']).'&key='.$new_key;
$your_email = 'test@test.com'; 
$domain = $_SERVER["HTTP_HOST"];
$to = implode(',', $_POST['email1']);
$subject = 'Confirmation';
$message = '<font class="font1">
<a href="http://'.$domain.'/'.$activation.'">http://'.$domain.'/'.$activation.'</a></font>';

$headers .= 'MIME-Version: 1.0' . "\r\n";  
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";  
$headers .= "From: <$your_email>\r\n" .  
"X-Mailer: PHP/" . phpversion(); 

mail($to, $subject, $message, $headers);
?>

选择用户电子邮件地址的表单

<form name ="checkForm" id="checkForm" method="post">  
<?php 
$query=mysql_query("select semail from students order by id") 
or die ('students query');

while($row=mysql_fetch_array($query))
{
?>

<input type="text" name="email1[]" value="<?php echo $row['semail'] ?>"  />

<?php } ?> 

</form>

1 个答案:

答案 0 :(得分:1)

使用BCC

$headers .= 'From: Your Name <test@test.com' . "\r\n";
$headers .= 'BCC: '.  implode(',', $_POST['email1']) . "\r\n";

mail(null, $title, $content, $headers);