Hi,
I have this problem like some people with PHPMailer, and I cannot find any solutions on the internet. The problem is that PHPMailer sends duplicates (sometimes more than two) if I set it in a loop (while, foreach). I've checked the loop is just fine, but it keeps sending duplicates.
Here is the code after I made it looks simpler.
<?php
require("PHPMailer/class.phpmailer.php");
$select = mysql_query("SELECT * FROM `pm_mailmembers` WHERE `mm_interval`='2' AND mm_blocked = 0") or die(mysql_error());
$mail = new PHPMailer();
$mail->SingleTo = true;
$mail->CharSet = "UTF-8";
$mail->Subject = "Fiscanet Nieuws";
$sendContent = "<p>This is test mail</p>";
$r_receivers = array("John"=>"
[email protected]","Mary"=>"
[email protected]","Rob"=>"
[email protected]");
foreach($r_receivers as $name=>$email){
$mail->SetFrom('
[email protected]', "Yoursite");
$mail->MsgHTML($sendContent);
$mail->AddAddress($email, $name);
if($mail->Send())
echo "Sent to: ".$email."<br/>";
else
echo "Not sent to: ".$email.", reason: ".$mail->ErrorInfo."<br/>";
$mail->ClearAddresses();
}
?>
I think I need to reset mail->addaddress inside the loop, but mail->clearaddresses doesn't help. And all 3 emails always receives the same emails. So all receives 2 or 3 mails.
Could anyone help me out here?? Thanks.
ayok