PHPMailer 使用 BCC 群发邮件并捕获不成功的电子邮件地址

PHPMailer Mass mailing using BCC and catching not successfull email addressses

我正在尝试使用 PHPMailer 和我的 SMTP 服务器将 NewsLetter 发送给 1500 个用户。

我试过将邮件发送到2个BCC邮箱进行测试,都成功发送了邮件。 但在我继续将邮件发送到 1500 电子邮件地址之前,我有几个问题。

我正在使用这个代码片段。

<?php

require "../PHPMailer-master/PHPMailerAutoload.php";

$bcc_list = array('emailaddrs1,emailaddress2');

$mail             = new PHPMailer();

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.myserver.com"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "smtp.myserver.com"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "mailer@myserver.com"; // SMTP account username
$mail->Password   = "mypasss";        // SMTP account password

$mail->SetFrom('mailer@myserver.com', 'myserver Support');

$mail->AddReplyTo("mailer@myserver.com","myserver Support");

$mail->Subject    = "Email sent from xampp";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "support@myserver.com";
$mail->AddAddress($address, "support@myserver.com");


foreach($bcc_list as $bcc_email){
   $mail->AddBCC($bcc_email);
}

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
 //insert that emaill address into database for re-emailing.
} else {
  echo "Message sent!";
}

1) 我怎样才能使电子邮件在 <To> 字段中显示用户电子邮件地址而不是我的虚拟地址?

2) 它是以 1 封电子邮件还是 1500 封电子邮件的形式发送的? 即,我如何才能捕捉到哪些电子邮件已成功发送,哪些未成功发送(由于超时或出现问题)以便我可以再次发送它们,而不必向所有其他人发送垃圾邮件?

在您的代码中,您将一条消息发送到 1 个地址并密件抄送给所有其他地址,因此只有一个 To 地址 - 这就是密件抄送的工作原理。如果您想将每个收件人的地址显示为 To 地址,则必须单独发送每封邮件 - 查看 the mailing list example provided. If you want to spot failures in a long list of recipients of any kind, make sure you're using an up-to-date version of PHPMailer,因为这在过去是错误的。任何错误地址都将在 $mail->ErrorInfo.

中报告