added mailing tool
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
require($opt['rootpath'] . 'lib2/web.inc.php');
|
||||
|
||||
|
||||
$rs = sql("SELECT email FROM user WHERE NOT ISNULL(email) and is_active_flag!=0");
|
||||
$rs = sql("SELECT email FROM user WHERE NOT ISNULL(email) and is_active_flag!=0 ORDER BY user_id DESC");
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
{
|
||||
echo $r['email'] . "\n";
|
54
htdocs/util-local/mailing/mailing.php
Normal file
54
htdocs/util-local/mailing/mailing.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* send mailing
|
||||
*
|
||||
* For license information see doc/license.txt
|
||||
***************************************************************************/
|
||||
|
||||
// reads from addesses.txt
|
||||
// writes protocol sent.txt
|
||||
// sends email to all recipients from addresses.txt which are not contained in sent.txt
|
||||
//
|
||||
// may be resumed after interrupt
|
||||
|
||||
ini_set('memory_limit', '128M');
|
||||
|
||||
// read recipients' email addresses
|
||||
$addresses = file("addresses.txt");
|
||||
$protocol = @file("sent.txt");
|
||||
if ($protocol === false)
|
||||
$sendto = $addresses;
|
||||
else
|
||||
$sendto = array_diff($addresses,$protocol);
|
||||
|
||||
// read message text
|
||||
$message = file_get_contents("message.txt");
|
||||
if (empty($message)) die();
|
||||
|
||||
$total = count($sendto);
|
||||
$n = 0;
|
||||
echo "sending email to " . $total . " of " . count($addresses) . " recipients\n\n";
|
||||
|
||||
$subject = "....";
|
||||
$from_adr = "user@do.main";
|
||||
|
||||
$starttime = microtime(TRUE);
|
||||
|
||||
foreach($sendto as $receiver)
|
||||
{
|
||||
$receiver = trim($receiver);
|
||||
echo ++$n . "/$total: $receiver";
|
||||
mail($receiver,
|
||||
$subject,
|
||||
$message,
|
||||
"From: $from_adr\r\n" .
|
||||
"MIME-Version: 1.0\r\n" .
|
||||
"Content-Type: text/plain; charset=iso-8859-1\r\n" .
|
||||
"Content-Transfer-Encoding: 8bit");
|
||||
echo "\n";
|
||||
file_put_contents("sent.txt", "$receiver\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
echo "Time needed: " . (microtime(TRUE) - $starttime) . "s\n";
|
||||
|
||||
?>
|
Reference in New Issue
Block a user