Note that there are some explanatory texts on larger screens.

plurals
  1. POPHPMailer sends duplicates in a loop
    primarykey
    data
    text
    <p>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. </p> <p>Here is the code after I made it looks simpler. </p> <pre><code>&lt;? 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-&gt;SingleTo = true; $mail-&gt;CharSet = "UTF-8"; $mail-&gt;Subject = "Fiscanet Nieuws"; $sendContent = "&lt;p&gt;This is test mail&lt;/p&gt;"; $r_receivers = array("John"=&gt;"john@mail.com","Mary"=&gt;"mary@mail.com","Rob"=&gt;"rob@mail.com"); foreach($r_receivers as $name=&gt;$email){ $mail-&gt;SetFrom('no-reply@yoursite.com', "Yoursite"); $mail-&gt;MsgHTML($sendContent); $mail-&gt;AddAddress($email, $name); if($mail-&gt;Send()) echo "Sent to: ".$email."&lt;br/&gt;"; else echo "Not sent to: ".$email.", reason: ".$mail-&gt;ErrorInfo."&lt;br/&gt;"; $mail-&gt;ClearAddresses(); } ?&gt; </code></pre> <p>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. </p> <p>Could anyone help me out here?? Thanks. ayok</p> <hr> <p>The problem get even wierder... I've tried to change the code to just a simple mail(), and it keep sending duplicates. What could be the cause? Is it a server configuration problem??</p> <p>I did this in the subdomain of mysite.com, say sub.mysite.com. Mysite.com and sub.mysite.com are in different servers. Could it be the cause?</p> <p>Thanks, ayok</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload