Allora ti spiego meglio... io ho una pagina crea_newsletter.php nel quale è presente il form per creare la mail:
Codice PHP:
....
<form method="post" action="manda.php">
....
<input type="submit" value="Invia">
</form>
....
che a sua volta punta al file manda.php (codice analizzato fino ad ora):
Codice PHP:
session_start();
$return_email = "mailinglist@***";
$reply_email = "mailinglist@***";
$body = $_POST['corpo'];
$title = $_POST['titolo'];
$getemail = mysql_query("SELECT email FROM newsletter") or die(mysql_error());
$cont=0;
$arrErr = array();
while($data=mysql_fetch_array($getemail)) {
$email=$data["email"];
$header = "From: $return_email\nReply-To: $return_email\nContent-Type: text/html; charset=iso-8859-1";
if ($cont==10) {
sleep(5);
$cont=0;
}
$cont++;
// Salvo l'email per la quale si è verificato l'errore
// Puoi salvarti anche un messaggio o quant'altro ti pare
if(!mail("$email", "$title", "$body", "$header"))
$arrErr[] = $email;
if(count($arrErr) > 0) {
// Gestisci l'errore che sai si è verificato per ogni email presente nell'array
echo"Errore";
exit();
}
else {
header("Location: messaggio.php?messaggio=Inviata correttamente!");
exit();
}
?>
che a sua volta punta a messaggio.php che stampa il messaggio nella pagina con formattazione CSS:
Codice PHP:
<?php
echo '
<p id="messaggio"><h2>'.$_REQUEST["messaggio"].'</h2></p>
'
?>
Grazie mille.