Index: tokens.php =================================================================== --- tokens.php (revision 9877) +++ tokens.php (working copy) @@ -304,6 +304,9 @@ $datelcu = strtotime($lasthinfo->date); $datelastbounce= $datelcu; $lastbounce = $thissurvey['bouncetime']; + $earliestinfo=imap_headerinfo($mbox,1); + $earliestdate=strtotime($earliestinfo->date); + if($lastbounce<$earliestdate) $lastbounce=$earliestdate; while($datelcu > $lastbounce) { $header = explode("\r\n", imap_body($mbox,$count,FT_PEEK)); // Don't put read @@ -334,8 +337,8 @@ $datelc=$lasthinfo->date; $datelcu = strtotime($datelc); $checktotal++; - imap_close($mbox); } + imap_close($mbox); $entertimestamp = "update ".db_table_name("surveys")." set bouncetime='$datelastbounce' where sid='$surveyid'"; $executetimestamp = $connect->Execute($entertimestamp); if($bouncetotal>0)