La modifica che devo fare serve per aggirare l'errore di timeout restituito dal server; questo errore è causato dall'elevato numero di indirizzi email presenti nel database, infatti lo script fa solo in tempo a spedire 250 email e poi va in timeout.
Guardate il codice sottostante:
codice:
function send_newsletter() {
global $id, $return_email, $tid;
news_admin();
$dbcnx = dbopen();
$getnewsletter = mysql_query("SELECT title, news_body FROM news_letter WHERE id='$id'") or die(mysql_error());
while($d=mysql_fetch_array($getnewsletter)) {
$body=$d["news_body"];
$title=$d["title"];
$tid = "0";
$text = make_it_text($body);
}
$getemail = mysql_query("SELECT email, header FROM sub_mail") or die(mysql_error());
while($data=mysql_fetch_array($getemail)) {
$type=$data["header"];
$email=$data["email"];
//
//Se l'email è in formato HTML
if($type == "H") {
$header = "From: $return_email\nReply-To: $return_email\nContent-Type: text/html; charset=iso-8859-1";
//
// Edit unsubscribe message and url path for your site
//
mail("$email", "$title", "$body \n\nYou are currently subscribed to our newsletter mailing list as $email.\nTo unsubscribe, click here: <a href=\"http://your_site/newsletter/add_unsub.php?f=unsub_email&email=$email\">Unsubscribe</a>", "$header");
}
//
//Se l'email è in formato testo
if($type == "T") {
$header = "From: $return_email\nReply-To: $return_email\nContent-Type: text/plain; charset=iso-8859-1";
//
// Edit unsubscribe message and url path for your site
//
mail("$email", "$title", "$text \n\nYou are currently subscribed to our newsletter mailing list as $email.\nTo unsubscribe, click here: http://your_site/newsletter/add_unsu...b_email&email=$email", "$header");
}
}
if(mail) {
msg("Newsletter Successfully Sent!");
} else {
msg("Error sending Newsletter!
<a href=\"javascript:history.go(-1)\" title=\"Torna indietro\"><< Torna indietro</a>");
}
echo "</body></html>";
mysql_close($dbcnx);
}
Questa funzione serve a spedire tutte le email agli scritti nel database; io non conosco il PHP e dovrei modificare il particolarmodo questa parte di codice
codice:
$getemail = mysql_query("SELECT email, header FROM sub_mail") or die(mysql_error());
while($data=mysql_fetch_array($getemail)) {
$type=$data["header"];
$email=$data["email"];
Qui viene caricato l'array con tutti gli indirizzi email (1000, 2000 ...non so quanti indirizzi ci sono).
Vorrei inserire un contatore parziale il quale conta il numero delle email spedite. Arrivato a quota "200 email spedite" viene creata la pagina di output con scritto:
"spedite 200 email di xxx email. Vuoi continuare?"
Una volta data la conferma la spedizione riprende dalla email 201 fino alle successive 200 email, ecc... fino alla completa spedizione di tutte le email presenti nel database.
Sono riuscito a spiegarmi....
Thanks!