Well, you can use the following commands :
mysql_connect();
mysql_select_db(thejuggalos);
$result = mysql_query("SELECT * FROM mail_list");
while ($i = mysql_fetch_object($result))
{ $newfile = $i->name;
$newlink = $i->em;
echo("Name : " . $newfile);
echo("E-Mail : " . $newlink);
echo("Sending mail to : " . $newfile . " at email address " . $newlink);
$mail_to = $newlink;
$mail_subject = "Subject";
$mail_body = "This is just a message for testing.\n";
$mail_body .= "Thanking you, we remain.\n";
$mail_body .= "Yours truly\n";
$mail_body .= "Subodh Arora\n";
if(mail($mail_to, $mail_subject, $mail_body))
echo ("Successfully sent the e-mail to " . $newfile . " at " . $mail_to);
else echo ("Failed to send the e-mail " . $newfile . " at " . $mail_to);
}
mysql_close()
?>
Hope it will demonstrate you the mail function of php.