Internal Server Error (Aruba hosting)
Posted: Fri Aug 22, 2008 11:07 am
Hi to all,
I have to send a newsletter to more than 2000 addresses on hosting Aruba...
I received the "Internal Server Error" error.
I searched a topic about this problem but I found anything.
I already set the variable max_execution_time to 900.
My SMTP is: smtp:aruba.it on Linux hosting.
SERVER_SOFTWARE: Apache/2.2
PHP Version: 5.2.6
System: Linux
The exact error is:
------------------------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, postmaster@miosito.it and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
PS: server logs are not available...
--------------------------------------
Now I try to post the code..
Sorry for my spaghetti code but I had no time to write properly and I changed so many times the the code...
Thanks
Sincerely I am desperate enough and I thank in advance anyone who wants to help me:)
I have to send a newsletter to more than 2000 addresses on hosting Aruba...
I received the "Internal Server Error" error.
I searched a topic about this problem but I found anything.
I already set the variable max_execution_time to 900.
My SMTP is: smtp:aruba.it on Linux hosting.
SERVER_SOFTWARE: Apache/2.2
PHP Version: 5.2.6
System: Linux
The exact error is:
------------------------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, postmaster@miosito.it and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
PS: server logs are not available...
--------------------------------------
Now I try to post the code..
Sorry for my spaghetti code but I had no time to write properly and I changed so many times the the code...
Thanks
Code: Select all
<?php
require 'testa.php';
$met = '900';
$fdd = '20';
$anteprima = stripslashes($_POST['anteprima_seria']);
// includo le librerie necessarie alla connnessione al database
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
include "mdb-database/config.inc.php";
$swift =& new Swift(new Swift_Connection_SMTP("smtp.aruba.it", 25));
// estendo il max_execution_time a TOT minuti per ogni invio in blocco
set_time_limit(0);
ini_set('max_execution_time', $met);
ini_set('display_errors', 'Off');
ini_set('memory_limit','16M');
// id newsletter
$id_nl = htmlspecialchars($_POST['id']);
// OGGETTO DELLA NEWSLETTER
$path = 'http://www.mysite.com/';
// TESTO DELLA NEWSLETTER
$testo = '';
$testo .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv=Content-Type content="text/html; charset=UTF-8" /><title>Newsletter</title>';
$testo .= '<META http-equiv="Content-Type" content="text/html; charset=UTF-8">';
$testo .= '<link rel="stylesheet" type="text/css" href="'.$path.'style.css" />';
$testo .= '</head><body>';
// CONTENT
$testo .= $_POST['anteprima_seria'];
$testo .= '</body></html>';
// IMPOSTO LA NEWSLETTER COME "INVIATA"
$sql_nl_inviata = 'UPDATE archivio SET inviata="1", data_invio="'.date("Y-m-d").'" WHERE id="'.$id_nl.'"';
@mysql_query($sql_nl_inviata, $conn);
// PREPARO ED ESEGUO L'INVIO
// calcolo il numero di blocchi da considerare
$sql_count_indirizzi = 'SELECT COUNT(*) FROM newsletter';
$res_count = mysql_query($sql_count_indirizzi, $conn)
or die(mysql_error());
// controllo se il numero di indirizzi è maggiore del numero di indirizzi per blocco
$numero_iscritti_tmp = mysql_fetch_row($res_count);
$numero_iscritti = $numero_iscritti_tmp[0];
if($numero_iscritti>$fdd){
// divido il numero di iscritti totali per il numero di blocchi desiderato
$n_blocchi = ($numero_iscritti/$fdd);
// arrotondo il risultato ad un intero
if(is_float($n_blocchi))
$n_blocchi = (int)$n_blocchi+1;
else
$n_blocchi = (int)$n_blocchi;
}
else
$n_blocchi = 1;
// per ogni blocco effettuo una query chiedendo un preciso range di indirizzi
for($i = 0; $i < $n_blocchi; $i++){
// controllo se il blocco è il primo (parte da 0) o uno dei
// successivi
if(($i+1) <= $n_blocchi){
// selezioni il range di record da mostrare
$da = ($fdd * $i);
$limit = ' LIMIT '.$da.', '.$fdd;
}
else
$limit = ' LIMIT 0, '.$fdd;
// eseguo la query che restituisce il blocco di indirizzi interessato
$sql_blocco_indirizzi = 'SELECT email FROM newsletter '.$limit;
$res_blocco = mysql_query($sql_blocco_indirizzi, $conn)
or die(header('Location: '.$_SERVER['PHP_SELF']));
$numero = mysql_num_rows($res_blocco);
while($numero>0){
echo '<span style="display: none"> </span>';
/*
ob_end_clean();
ob_flush();
flush();
*/
--$numero;
$val = mysql_fetch_row($res_blocco);
$message =& new Swift_Message($_POST['oggetto'], $testo, "text/html");
if (!($swift->send($message, trim($val[0]), "info@address.com"))){
echo "Si è verificato un errore durante l'invio dell'indirizzo ".$val[0];
exit();
}
else
echo $val[0].' fatto!<br />';
}
}
//$swift->disconnect();
//header('Location: esito.php?confirm=newsletter');
##########################################
/*
ob_end_clean();
ob_flush();
flush();
*/
echo '<meta http-equiv="refresh" content="0;URL=esito.php?confirm=newsletter">';
echo '<div>';
echo '<table class="list" style="font-size: small">';
echo '<tr><td colspan="2">';
echo '<div class="conferma" style="font-size: small" id="esito">L\'invio è stato effettuato con successo!</div>';
echo '<br />';
$op= 'gestisci_email.php';
echo '<div>';
echo '<a href="'.$op.'">« TORNA ALLA LISTA DELLE E-MAIL</a>';
echo '</div>';
echo '</td></tr>';
echo '</table>';
echo '</div>';
// includo la coda
require 'coda.php';
?>