";}
$subject = $HTTP_POST_VARS['subject'];
$subject = htmlspecialchars(stripslashes($subject));
if(!$subject){echo("Опять же, кто будет писать тему сообщения?");}
$type = $HTTP_POST_VARS['type'];
$message = $HTTP_POST_VARS['message'];
if($type == 'text'){$message = htmlspecialchars(stripslashes($message));}
if(!$message){echo("Короче, нужно что то написать. Где сообщение-то?"); exit;}
############################################################################
$to_arr = file(@$HTTP_POST_FILES['to']['tmp_name']);
// print_r($to_arr);exit;
$to_arr = array_unique($to_arr);
$i = 0;
$current_message= 0;
$num_send = 0;
$num_bad = 0;
$num_error= 0;
while(isset($to_arr[$i])){
$to_arr[$i] = trim($to_arr[$i]);
if(sendemail($from,$to_arr[$i],$subject,$message,$type)){
echo('Сообщение на '.$to_arr[$i]." отправлено
\n"); flush();
$num_send++;
}
else{$num_error++;}
$current_message++;
if($current_message == $message_in_min){
$current_message = 0;
echo('Отправлено '.$message_in_min.' соообщений. Пауза 60 сек.'."
\n");
flush();
sleep(30);
echo(''."\n");
flush();
sleep(30);
}
$i++;
}
echo('
Рассылка завершена!
'."\n");
echo('
Отправлено : '.$num_send.'
Ошибок связи: '.$num_error.'
Плохих email: '.$num_bad.'
');
break;
default:
echo('
');
break;
}
function sendemail($from,$to,$subject,$message,$type){
$bound = time().'SPB';
global $attach, $base_name, $isfile;
$sep = chr(13).chr(10); // Разделитель строк заголовка
switch($type){
case 'text':
$headers = "From: ".$from.$sep;
$headers.= "X-Priority: 3".$sep;
$headers.= "X-MSMail-Priority: Normal".$sep;
$headers.= "X-Mailer: PHP/".phpversion().$sep;
$headers.= "MIME-Version: 1.0".$sep;
$headers.= "Content-Type: multipart/mixed; boundary=\"".$bound."\"".$sep.$sep;
$body = "--$bound".$sep;
$body.= "Content-type: text/plain; charset=\"windows-1251\"".$sep;
$body.= "Content-Transfer-Encoding: 8bit".$sep.$sep;
$body.= $message.$sep;
if($isfile == 1){
$body.= "$sep$sep--$bound".$sep;
$body.= "Content-Type: application/octet-stream;";
$body.= "name=\"".basename($base_name)."\"".$sep;
$body.= "Content-Transfer-Encoding:base64".$sep;
$body.= "Content-Disposition:attachment".$sep.$sep;
$body.= $attach.$sep;
}
// $body.="$bound--".$sep.$sep;
break;
case 'html':
$headers = "From: ".$from.$sep;
$headers.= "X-Priority: 3".$sep;
$headers.= "X-MSMail-Priority: Normal".$sep;
$headers.= "X-Mailer: PHP/".phpversion().$sep;
$headers.= "MIME-Version: 1.0".$sep;
$headers.= "Content-Type: multipart/mixed; boundary=\"".$bound."\"".$sep.$sep;
$body = "--$bound".$sep;
$body.= "Content-type: text/html; charset=\"windows-1251\"".$sep;
$body.= "Content-Transfer-Encoding: 8bit".$sep.$sep;
$body.= $message.$sep;
if($isfile == 1){
$body.= "$sep$sep--$bound".$sep;
$body.= "Content-Type: application/octet-stream;";
$body.= "name=\"".basename($base_name)."\"".$sep;
$body.= "Content-Transfer-Encoding:base64".$sep;
$body.= "Content-Disposition:attachment".$sep.$sep;
$body.= $attach.$sep;
}
// $body.="$bound--".$sep.$sep;
break;
default:
echo('Неверный параметр типа письма.');
break;
}
if(mail($to,$subject,$body,$headers)){return true;}
else{return false;}
}
?>