<?
//FINER sender


include("opt.ini");
$fileaddr = "addr.ini";//Спам-лист
$filemsg  = "msg.ini"; //Сообщение


If ($page == "send") {
 $f = file($fileaddr);
 $f2 = file($filemsg);
 $msg = "";
 for ($s = 0; $s < count($f2); $s++) {
  $msg .= trim($f2[$s]) . "\n";
 }

 for ($i = $nf; $i < $nt; $i++) {
  mail(trim($f[$i]), $subject, $msg, "From: $fromname <$frommail>\nContent-Type: text/plain;\n        charset=windows-1251\nX-Priority: $priority");
 }
 $b=$i++;
 echo "<p><b>Все $b  писем разосланы</b></p>\n";
}
Else {
 $f2 = file($fileaddr);
 for ($e = 1; $e < ceil(count($f2) / 500 +1); $e++) {
  If ($e*500 > count($f2)) {
   $nt = count($f2);
  }
  Else {
   $nt = $e*500;
  }
  $nf = $e*500-500;
  $nf1 = $nf+1;

  echo "<p><a href='index.php?page=send&nf=$nf&nt=$nt' target='_blank'>Рассылка писем с $nf1 по $nt</a></p>\n";
 }
}
?>
