Witam mam dość dziwny problem z wysłaniem newslettera
wysłam teortycznie po 40 e-maili , w pętli, potem chiwle czeka i wysła kolejne maile (przynajmniej tak mi się wydaje ze powinno robić)
A w praktyce wysłał mi jedną wielką niewiadomą, do 40 osób po X emaili potem do innych znow, skrypt mi totalnie ześwirował i nie wiem dlaczego.

Podaje kod wysłania:
  1. <?php
  2. $q = $this->engine->db->queryf('SELECT `id`, `email` FROM `%t` WHERE `wyslane`=0 ORDER BY `id` ASC LIMIT 40', 'newsletter');
  3.  
  4. while($r = $q->fetch())
  5. {
  6. $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  7.  
  8. $mail->IsSMTP(); // telling the class to use SMTP
  9. $mail->Host = "xxxyyy.zzz.com"; // SMTP server
  10. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  11. $mail->SMTPAuth = false; // enable SMTP authentication
  12. $mail->Host = "xxxyyy.zzz.com"; // sets the SMTP server
  13. $mail->Port = 25; // set the SMTP port for the GMAIL server
  14. $mail->Username = "zzz"; // SMTP account username
  15. mail->Password = "zzz1 "; // SMTP account password
  16. $mail->charset = 'iso-8859-2';
  17. $mail->ContentType = 'text/plain';
  18. $mail->Encoding = 'base64';
  19. $mail->fromName = 'zzzz zzzz xxx yyy';
  20. $mail->SetFrom('zzz@xxxyyy.pl', 'zzz zzz xxx yyy');
  21. $wiadomosc .= '<html>
  22. <head>
  23. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  24. </head>
  25. <body>';
  26. $wiadomosc .= '<a href="http://xxxyyy.pl/?path=newsletter_czytaj-'.$_SESSION['szablon']['id']['id'].'">Kliknij w ten link jeśli masz problemy z odczytaniem tej wiadomości</a>';
  27. $wiadomosc .= $_SESSION['szablon']['mail'];
  28. $wiadomosc = str_replace('repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;', ';', $wiadomosc);
  29. $wiadomosc = str_replace('transparent ', '', $wiadomosc);
  30. $wiadomosc .= '</body></html>';
  31. $mail->Subject = $_SESSION['szablon']['title'];
  32. $mail->MsgHTML($wiadomosc);
  33. $lastid = $this->engine->db->queryf('SELECT `id` FROM `%t` ORDER BY `id` DESC LIMIT 1', 'newsletter')->fetch();
  34. $lastid = $lastid['id'];
  35. $mail->AddAddress($r['email'], '');
  36. #echo $r['email'].'<br />'.$wiadomosc;
  37. $mail->Send();
  38. if($lastid == $r['id'])
  39. {
  40.  
  41. $this->engine->db->queryf('UPDATE `%t` SET `wyslane`=0', 'newsletter');
  42. header('location:'.$this->engine->router->make_link_by_clip(0, 'ok'));
  43. exit;
  44. }
  45. }
  46.  
  47. $this->engine->db->queryf('UPDATE `%t` SET `wyslane`=1 WHERE `wyslane`=0 ORDER BY `id` ASC LIMIT 40', 'newsletter');
  48.  
  49. }
  50.  
  51. }
  52.  
  53. ?>


I tutaj moje pytanie jakim cudem jest to możliwe, skoro za każdym razem tworzę nowy obiekt?