<?php
mb_internal_encoding("UTF-8");
header('Content-type: text/html; charset=utf-8'); require_once('class.phpmailer.php');
if(!isset($_GET['offset'])) $_GET['offset'] = 0; $limit = '20';
$mails = mysql_query('SELECT `email` FROM `tabela` LIMIT '.$_GET['offset'].', '.$limit.''); if(mysql_num_rows($mails) == 0
) die('Koniec, wysłałem '.$_GET['offset'].' wiadomości.'); $cnt = 0;
$address = $row['email'];
$mail = new PHPMailer();
$mail->CharSet="UTF-8";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.xxx.pl"; // SMTP server
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "host.pl"; // sets the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "adres@mail.pl"; // SMTP account username
$mail->Password = "pa$w00rd"; // SMTP account password
$mail->SetFrom('adres@mail.pl', 'TEMAT');
$mail->AddReplyTo("adres@mail.pl","TEMAT");
$mail->Subject = "TEMAT";
$mail->AltBody = "TEMAT"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($address, $address);
// $mail->AddAttachment("images/phpmailer.gif"); // attachment
// $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) exit("Mailer Error: " . $mail->ErrorInfo); $cnt++;
$mail = null;
}
echo 'Koniec, wysłałem '.$cnt.' wiadomości.'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Refresh" content="4; URL=index.php?offset=
<?php echo $_GET['offset']+$limit; ?>" />
<title> newsletter</title>
</head>
<body>
Wysyłanie mailingu w trakcie. Do tej pory wysłano
<?php echo $_GET['offset']+$limit; ?> wiadomości.
</body>
</html>