title: phpmailer send to multiple emails including unique unsubscribe link
body: <p>I am making php script to send newsletter with option to unsubscribe for each recipient.</p>
  
  <p>The code below works - sends and email to each subscriber which i have in DB. However it adds unsubscribe links to everyone. So if i have 2 subscribers they both get same message body AND 2 links to unsubcscribe.</p>
  
  <p>Here is the code.</p>
  
  <pre><code>if (isset($_POST['sendemail'])) {
      require_once "phpmailer/class.phpmailer.php";
      require_once "phpmailer/class.smtp.php";
      $message = "TEST MESSAGE";
      $mail = new PHPMailer();
      $body = eregi_replace("[\]",'',$message);
      $mail-&gt;IsSMTP();
      $mail-&gt;SMTPAuth = true;
      $mail-&gt;SMTPSecure = 'ssl';
      $mail-&gt;Host = "myserver";
      $mail-&gt;Port = 465;
      $mail-&gt;Username = "myuser";
      $mail-&gt;Password = "mypass";
      $mail-&gt;SMTPDebug = false;
      $mail-&gt;do_debug = 0;
      $mail-&gt;SetFrom("me@domain.ltd", "Me");
      $mail-&gt;AddReplyTo("me@domain.ltd", "Me");
      $mail-&gt;AddAddress("some@email.com", "member");
      // I GET LIST OF SUBSCRIBED EMAILS AND LOOP THE MAIL SENDING
      $result = dbquery("SELECT * FROM emails WHERE email_sub='1'");
      while($row = dbarray($result)) {
          // HERE SHOULD BE ONIQUE UNSUBSCRIBE LINKO FOR EACH EMAIL
          $body .= "&lt;br /&gt;&lt;a href=\"http://someurl.tld/emails.php?email=".$row["email_address"]."\"&gt;Unsubscribe&lt;/a&gt;";
          $mail-&gt;Subject = $subject;
          $mail-&gt;MsgHTML($body);
          $mail-&gt;WordWrap = 50;
          $mail-&gt;AddBCC($row["email_address"], $row["email_name"]);
          $mail-&gt;addCustomHeader("List-Unsubscribe","&lt;admin@keepity.com&gt;, &lt;http://keepity.com/?email=".md5(md5($row["email_address"]))."&gt;");
      }
      if(!$mail-&gt;Send()) {
          echo "&lt;i class=\"fa fa-warning\"&gt;&lt;/i&gt; Error: " . $mail-&gt;ErrorInfo."&lt;br /&gt;";
      } else {
          echo "Done";
      }
  }
  </code></pre>
  
  <p>so email looks like this</p>
  
  <pre><code>Message body.....
  
  Unsubscribe
  Unsubscribe
  </code></pre>
  
  <p>So if i had 100 subscribers there would be 100 links in each email..</p>