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:
<?php
$q = $this->engine->db->queryf('SELECT `id`, `email` FROM `%t` WHERE `wyslane`=0 ORDER BY `id` ASC LIMIT 40', 'newsletter');
while($r = $q->fetch())
{
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "xxxyyy.zzz.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = false; // enable SMTP authentication
$mail->Host = "xxxyyy.zzz.com"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "zzz"; // SMTP account username
mail->Password = "zzz1 "; // SMTP account password
$mail->charset = 'iso-8859-2';
$mail->ContentType = 'text/plain';
$mail->Encoding = 'base64';
$mail->fromName = 'zzzz zzzz xxx yyy';
$mail->SetFrom('zzz@xxxyyy.pl', 'zzz zzz xxx yyy');
$wiadomosc .= '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
</head>
<body>';
$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>';
$wiadomosc .= $_SESSION['szablon']['mail'];
$wiadomosc = str_replace('repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;', ';', $wiadomosc); $wiadomosc = str_replace('transparent ', '', $wiadomosc); $wiadomosc .= '</body></html>';
$mail->Subject = $_SESSION['szablon']['title'];
$mail->MsgHTML($wiadomosc);
$lastid = $this->engine->db->queryf('SELECT `id` FROM `%t` ORDER BY `id` DESC LIMIT 1', 'newsletter')->fetch();
$lastid = $lastid['id'];
$mail->AddAddress($r['email'], '');
#echo $r['email'].'<br />'.$wiadomosc;
$mail->Send();
if($lastid == $r['id'])
{
$this->engine->db->queryf('UPDATE `%t` SET `wyslane`=0', 'newsletter');
header('location:'.$this->engine->router->make_link_by_clip(0, 'ok')); }
}
$this->engine->db->queryf('UPDATE `%t` SET `wyslane`=1 WHERE `wyslane`=0 ORDER BY `id` ASC LIMIT 40', 'newsletter');
}
}
?>
I tutaj moje pytanie jakim cudem jest to możliwe, skoro za każdym razem tworzę nowy obiekt?