I've a script to send packages of 300-500 e-mails hour. That means that this script will be fired once a hour using cron or other feature.
The server has a max execution limit of 30secs and it's not configurable.
I've been thinking if the pseudo-code below should work:
$time=time();
$count=0;
while(condition){
$count++;
send(email);
$now=time();
if($now-$time>=29){break;} //1sec margin
}
echo "$count e-mails sent";
Opinions?