Mi sono accorto che la mail arriva solo al primo estratto dalla tabella. Come mai non esegue il ciclo e non la manda a tutti?Codice PHP:
require("include/class.phpmailer.php"); //usata solo per mailing_list
$mail = new phpmailer();
$mail->From = "info@ancoravela.it";
$mail->FromName = "AncoraVela Newsletter";
//$mail->Host = "smtp1.example.com;smtp2.example.com";
//$mail->Mailer = "smtp";
$query= mysql_query("SELECT email FROM mailing_list")
or die("Query Fallita: " . mysql_error());
$result = mysql_num_rows($query);
if ($result == 0) {
echo "non ci sono indirizzi mail nella tabella del db";
} else {
while ($row = mysql_fetch_array($query))
{
$mail->AddBCC($row["email"]); // email, nome
}
// HTML body
$body = "<img src=\"http://lnx.ancoravela.it/images/logo.gif\" width=\"314\" height=\"185\">
";
$body .= "Ciao,
";
$body .= "".$_POST['testo']."";
// Plain text body (for mail clients that cannot read HTML)
$text_body = "<img src=\"http://lnx.ancoravela.it/images/logo.gif\" width=\"314\" height=\"185\">
";
$text_body .= "Ciao, \n\n";
$text_body .= "".$_POST['testo']."";
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->Subject = "".$_POST['data']."";
$mail->AddReplyTo("info@ancoravela.it");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
echo "
<a href=\"mailing_list.php?action=testo\">OK</a>";
exit;
} else {
echo "email inviate";
echo "
<a href=\"mailing_list.php?action=testo\">OK</a>";
}
$mail->ClearBCCs();
}
} // chiudo controllo campi vuoti