[UPHPU] Sending an email between specific times.

Kyle Waters unum at unum5.org
Thu Jul 26 11:45:35 MDT 2007


Ash wrote:
>
> After reading a few of the comments here, I definitely want to so the 
> timing in my script instead of cron, so I'll be able to break it and 
> then start it back up as soon as it's 10:00 PM again.

$starting_email=file('last_email.txt')[0];
$emails=file('emails.txt');
$start=false;
while(($email=next($emails))&&((date('H')>22)||(date('H')<4)){
    if($email==$starting_email){
       $start=true;
    }
    if($start){
       mail($email,$header,$body);
    }
}
$last_email_file=fopen('last_email.txt');
if(current($emails)!=null){
    fwrite($last_email_file,current($emails));
}
else{
    fwrite($last_email_file,$emails[0]);
}

There's probably a better way to do that.  In fact I really doubt that
code will work(I don't use the current, next stuff much and it probably
doesn't work quite like that), but I would probably implement it
something like that.  Though if your server can't send 20,000 emails out
with in six hours you might want to consider new hardware.

Kyle


-- 
no amount of fear can stop the rise of free media, or free software 
(they are the same, after all)

Jonathan Swartz
CEO Sun Microsystems




More information about the UPHPU mailing list