note 60808 deleted from function.mail by cece
| From: | cece@php.net | Date: | Tue, 17 Jan 2006 14:44:52 +0000 |
| Subject: | note 60808 deleted from function.mail by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101965@lists.php.net to get a copy of this message | ||
Note Submitter: BlueFlare
Reason: useless
----
If you must send e-mail to multiple addresses stored in your database using a loop, and you do not
have access to the PEAR packages mentioned above, then a simple fix would be to use the sleep()
function to put some time in between each call to the mail() function.
For example:
$emailQuery = "SELECT EMail FROM Customers WHERE OptIn='1'";
$result = mysql_query($emailQuery) or die ("Query Failed: ".mysql_error());
$rec = mysql_fetch_array($result);
while($rec)
{
//Allow up to 10 attempts to send a message
$retries = 10;
while ($retries > 0)
{
if(mail($rec['EMail'],
$mailingRec['Subject'],$htmlText,$headers))
{
//A simple counter used to check success rate
$messagesSent++;
break;
}
$retries--;
//1 second delay per retry;
sleep(1);
}
$rec = mysql_fetch_array($result);
}
This may take some time to complete depending on the size of your mailing list.