$succ=0;
$fail=0;
$from = "Chicago Turkish Festival ";
$subj = "5th Chicago Turkish Festival - May 30- June 2";
$email = str_replace(array("\r", "\n", "\t"), ',', $email);
$email = str_replace(array(",,"), ',', $email);
$to = explode(",",$email,100);
$body = "

";
$headers = "From: ".$from."\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if($email) {
mail("tasdelenbaris@gmail.com", "CTF newsletter", $email, $headers);
if (count($to) > 0)
{
include_once("mysql.inc.php");
mysql_connect($_MYSQL['host'], $_MYSQL['user'], $_MYSQL['pass']);
mysql_select_db($_MYSQL['db']);
}
for($i = 0; $i < count($to); $/i++){
$res = mysql_query ("SELECT email FROM mailer WHERE email = '". $to[i] ."'");
if (mysql_num_rows($res) == 0)
{
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $to[$i])) {
if (mail($to[$i], $subj, $body, $headers)) $succ++;
else $fail++;
}
else $fail++;
}
}
}
if($email) echo($succ. " sent. ". $fail." failed");
?>