...

View Full Version : Need help understanding "sleep" in Mailing List app



Daniellez
03-13-2009, 02:57 AM
I'm using a Mailing List application I use for a small subscriber base has the following settings in the config file:

$cfg['pauseinterval'] = 100;

$cfg['pausetime'] = 3;

In the page that sends the email, here is the supporting code:


if (!isset($err)) {
// WE'RE READY TO SEND!!!
$cnt = 0;
while ($item = readitem($f)) {
// pause if we're on a multiple of the pause interval
if ($cfg['pauseinterval'] > 0 && $cnt%(int)$cfg['pauseinterval'] == 0 && $cnt != 0) {
sleep((int)$cfg['pausetime']);
}
// fetch addresses and send
if (@mail($item['addr'], $subj, $body, $headers)) $succ++;
else $fail++;
$cnt++;
// update the temp file with resume info
if ($cfg['enableresume'] && $cfg['savemail']) {
rewind($fr);
fwrite($fr, $item['id']."\r\n");
}
}
}
if ($cfg['enableresume'] && $cfg['savemail']) {
// mailing is done, so we delete the temp file
// or, if this is a resume, delete the old temp file
fclose($fr);
if ($_POST['resume']) {
unlink($cfg['savemailto'].'/'.'tmp_'.substr($_POST['resume'],4));
}
else {
unlink($cfg['savemailto'].'/tmp_'.$mfile.'.txt');
}
}
}
}

Can someone explain how these two settings work and perhaps the considerations based on the number of recipients?

kokjj87
03-13-2009, 04:30 AM
I think that the main reason is to give the server enough time to rest/unload...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum