Hello,
I am new in PHP and I want a script for sending multiple emails using the php and i am calling that email address from database.I also want to change the status field from database from No to Yes once I send the particular emails. How to do that? I need a urgent help
Following is my code for calling the email address
<?
mysql_connect("localhost","root","123") or die(mysql_error()); // my database connection
mysql_select_db("localacct") or die(mysql_error());
$sql = "SELECT email FROM company where status='No'";
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res) )
{
$area .= $row['email']. ", ";
}
// read the list of emails from the file.
$email_list = explode(',', $area);
// count how many emails there are.
$total_emails = count($email_list);
// go through the list and trim off the newline character.
for ($counter=0; $counter<$total_emails; $counter++)
{
$email_list[$counter] = trim($email_list[$counter]);
}
$to = $email_list;
//echo $to;
$t0 = "";
$subject = "Test email";
$message = wordwrap($message, 100);
$from = "my email address";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $from";
mail($to,$subject,$message,$headers);
if ($count % 10 == 0) {
sleep(5); // this will wait 5 secs every 10 emails sent, and then continue the while loop
}
$count++;
}
?>
Many Thanks in advance.