Here's my solution:
Caller page:
<?php
I call the page with lynx and put in the background
$devnull= lynx -dump 'http://www.your.host.com/page.php?send=all' &;
?>
You can of course access the page with a browser directly.
BCC-mail script:
(assumes a db with mail content, maildb, and a db with recipents, mailuserdb.)
page.php:
<?php
$email = array();
$tmp = array();
$number_of_bcc = 95;
define("MAILPROGRAM","/usr/sbin/sendmail -t");
$machine_adress = 'ipnumber';
$errloc = '/'; # error location is root url
$admin = array('your@mail.adr');
$ghost_recipent = '';
$from_addr = '$addr';
$datum=date("ymd H:i:s",time());
$mail_footer = "";
for db conn
include ("includes/mysql_conn.inc");
get message
it don't have to be in a db...
$sql = "SELECT * FROM maildb";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
$subject=$row['subject'];
$body=$row['body'];
$body.=$mail_footer;
unset($sql);
unset($row);
unset($res);
switch($send){
case 'all':
$sql = "SELECT * FROM mailuserdb WHERE email != ''";
$res=mysql_query($sql);
while ($row=mysql_fetch_array($res)){
$email[]=$row['email'];
}
loop through email in steps of number_of_bcc
put each chunk of recipents
in bcc-field and mail
$n=0; # bcc tmp counter
$m=1; # mailcounter
while ($m<=count($email)){
$index=$m-1;
save up to number_of_bcc in tmp array
$tmp[]=$email[$index];
$n++;
test if we reached max number of bcc
or if current mail is the last
if ($n==$number_of_bcc ||
$m==( count($email) ) ){
send_bcc_mail($tmp,$subject,$body);
$n=0;
unset($tmp);
$tmp=array();
}
$m++;
}
done
break;
} # end switch
function send_bcc_mail($email,$subject,$body){
global $from_addr,$ghost_recipent;
$recipents=implode(",",$email);
$mp = popen(MAILPROGRAM, "w")
or print("Can't open sendmail");
fputs($mp, "Mime-Version: 1.0\n")
or print "Can't write to sendmail";
fputs($mp, "Content-Type: text/plain; charset=ISO-8859-1\n");
fputs($mp, "Content-Transfer-Encoding: 8bit\n");
fputs($mp, "To: $ghost_recipent\n");
fputs($mp, "From: $from_addr\n");
fputs($mp, "Bcc: $recipents\n");
fputs($mp, "Subject: $subject\n");
fputs($mp, $body . "\n");
pclose($mp)
and print "Can't close sendmail";
}
?>
HTH
Christian Albinsson
Korridor AB
christian.albinsson@korridor.se