【问题标题】:PHPMailer Mass mailing using BCC and catching not successfull email addresssesPHPMailer 使用密件抄送的群发邮件并捕获不成功的电子邮件地址
【发布时间】:2015-05-14 02:44:52
【问题描述】:

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

我已尝试将邮件发送到 2 封密件抄送电子邮件进行测试,并成功发送邮件。 但在我继续将邮件发送到 1500 电子邮件地址之前,我有几个问题。

我正在使用这个代码sn-p。

<?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) 我怎样才能让电子邮件在&lt;To&gt; 字段中显示用户的电子邮件地址而不是我的虚拟地址?

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

【问题讨论】:

  • 我很确定它实际上是内置在电子邮件协议中的,您无法检测到哪些是成功的。否则,此信息可能会被恶意使用以发现电子邮件地址以发送垃圾邮件。
  • @Sildoreth 我不是想找到哪个邮箱,我只是想找到我成功发送的那个,以防出现问题,例如脚本超时、大延迟和/或 SMTP服务器关闭连接,或将我踢出或限制密件抄送计数。

标签: php email phpmailer


【解决方案1】:

在您的代码中,您将一条消息发送到 1 个地址并密件抄送所有其他地址,因此只有一个 To 地址 - 这就是密件抄送的工作方式。如果您想让每个收件人的地址显示为To 地址,您必须单独发送每条消息 - 查看the mailing list example provided。如果您想在一长串任何类型的收件人中发现故障,请确保您使用的是up-to-date version of PHPMailer,因为这在过去是错误的。任何错误地址都将在$mail-&gt;ErrorInfo 中报告。

【讨论】:

  • 感谢您的回复,我尝试将 1500 封电子邮件放入密件抄送中,但 SMTP 服务器发送了 SMTP 错误:RCPT TO 命令失败:452 4.5.3 错误:收件人消息过多,所以我计算了并且他们允许To + BCC 一次点击总共 50 个电子邮件地址。所以我使用array_chunk和foreach循环上面的代码......
猜你喜欢
  • 1970-01-01
  • 2013-08-15
  • 1970-01-01
  • 2021-12-15
  • 2021-09-13
  • 2012-03-20
  • 1970-01-01
  • 2021-04-29
相关资源
最近更新 更多