Forum Moderators: coopster
<?php
// Make a MySQL Connection
mysql_connect("localhost", "web168-customer", "1rangers1") or die(mysql_error());
mysql_select_db("web168-customer") or die(mysql_error());
//Get Date
$eltiempo=time();
$lafecha=date("Y-m-d",$eltiempo);
// Get all the data from the "domainrenewal" table
$result = mysql_query("SELECT * FROM domainrenewal WHERE warningdate='$lafecha'")
or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Email
$to = $row['email'];
// Send
mail($to, 'My Subject', $row['email']);
}
?>
It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.