1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
// insérer les éléments rentrés dans le formulaire d'envoi
$sql="INSERT INTO newsletter_envoi (titre, contenu1, contenu2, contenu3, photo1, photo2) VALUES ('$titre', '$contenu1', '$contenu2', '$contenu3', '$repertoire', '$repertoire2')";
$req=mysql_query($sql) or die (mysql_error());
//sélectionner les emails dans la table
$sql2 = "SELECT email FROM newsletter";
$req2 = mysql_query($sql2) or die(mysql_error());
$compteur=0; // <= compteur Wink
$donnees_html = file_get_contents("http://nom_site/newsletter/newsletter.php");
while($data = mysql_fetch_assoc($req2))
{
$sql3="SELECT titre FROM newsletter_envoi ORDER BY id desc LIMIT 1";
$req3=mysql_query($sql3) or die(mysql_error());
$info=mysql_fetch_array($req3);
$to .= $data['email'];
$subject = $info['titre'];
$headers .="MIME-Version: 1.0 \n";
$headers .="From: lilie507@hotmail.com \n";
$headers .="Return-Path: Webmaster <lilie507@hotmail.com> \n";
$headers .="Content-Type: text/html; charset=iso-8859-1 \n";
$headers .="Reply-To: Webmaster <lilie507@hotmail.com>\n";
mail($to, $subject, $donnes_html, $headers);
if($compteur == 50)
{
sleep(1);
$compteur=0;
}
$compteur++;
}
mysql_close(); |
Partager