I have a database containing more than 2000 contacts, I want to use the mass mailing, but I do not know how to do it, I used this code but I think it is not useful because the number of mails is important and mail() can't work for mass mailing.
<?php
require ("bdd.php");
$sql = "SELECT adresse FROM newsletter WHERE envoie='1';";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$en_tete ='From: '. $row['adresse'] .''."\n";
$en_tete .='Reply-To: [email protected]'."\n";
$en_tete .='Content-Type: text/html; charset="iso-8859-1"'."\n";
$en_tete .='Content-Transfer-Encoding: 8bit';
$contenu ='<html><head><title>Envoie html</title></head><body><p>TEST !</p></body></html>';
mail($row['adresse'], 'Envoie mail', $contenu, $en_tete)
}
mysql_close();
?>
You can use PHPMAILER
I don't know whether below solution is useful for you or not.. But I am just suggesting alternative thinking to send mass emails without any issue like spamming or hosting provider's limit of email per hour etc.....
========
Additionally you can use your query with limit and update database column when email sent...
e.g.
Add additional column
'email_sent'in your database table...and change query to
With cronjob you can reset
email_sentto0again....or with simple link to script which contains query to reset / updateemail_sentto0for all 2000+ rows can be used...Please avoid mysql...... Try Mysqli or PDO rather..