Send Completed

0) { $timeunits = $timediff / ($total-$numLeft); $timediff = ($timeunits * $numLeft); } else { $timediff = 0; } $timewaiting = timedifference($timediff); ?>

Sending...

Your newsletter is currently being sent. Please do not close this window.

There are emails remaining in the queue.

Time taken so far (approx):
Time until completion (approx):

'; window.close();">Pause / Stop Sending (Can be resumed later)
0) { $throttle_check_result = mysql_query("SELECT * FROM " . $TABLEPREFIX . "sends_perhour WHERE SendID='".addslashes($SendID)."'"); if (mysql_num_rows($throttle_check_result) > 0) { $throttle_check = mysql_fetch_assoc($throttle_check_result); } else { $throttle_check = array('HourStarted' => $SYSTEMTIME, 'HourEnded' => $SYSTEMTIME, 'EmailsSent' => 0); mysql_query("INSERT INTO " . $TABLEPREFIX . "sends_perhour (SendID, HourStarted, HourEnded, EmailsSent) VALUES('" . addslashes($SendID) . "', '" . addslashes($SYSTEMTIME) . "', '" . addslashes($SYSTEMTIME) . "', 0)"); } $PAUSE = 3600/$CURRENTADMIN['PerHour']; // if they're over an hour out, then reset the hourended. this will actually get updated in the database below. if ($SYSTEMTIME - $throttle_check['HourEnded'] > 3600) $throttle_check['HourEnded'] = $SYSTEMTIME; // if the time between the last hourended and the hourstarted are less than the hour, then check the number per hour. $diff = (int)$throttle_check['HourEnded'] - (int)$throttle_check['HourStarted']; if ($diff > 0 && $diff < 3600) { if ($throttle_check['EmailsSent'] >= $CURRENTADMIN['PerHour']) { ?>

:: Send Information ::

Your newsletter has been paused. You have reached your limit of sending emails per hour.

'; window.close();">[Stop Sending -- You Can Always Resume Later]
= 3600) { $result = mysql_query("UPDATE " . $TABLEPREFIX . "sends_perhour SET HourStarted='".addslashes($SYSTEMTIME)."', HourEnded='".addslashes($SYSTEMTIME)."', EmailsSent=0 WHERE SendID='".addslashes($SendID)."'"); } } if ($do_send) { OutputPageFooter(false); } if($PageID=='DoSending' && $do_send) { if ($send['Completed'] != 1) { $max_ex=get_cfg_var('max_execution_time')-3; $time_start=getmicrotime(); $queries_to_run = array(); $unbuffered_result = mysql_unbuffered_query("SELECT MemberID, Format, Problems FROM " . $TABLEPREFIX . "send_recipients WHERE SendID='".addslashes($SendID)."' AND Problems='0' LIMIT 1"); $member_info = array(); while ($e = mysql_fetch_assoc($unbuffered_result)) { $e = stripslashes_array($e); $member_info[] = $e; } mysql_free_result($unbuffered_result); foreach($member_info as $pos => $e) { if (in_array($e['MemberID'], $_SESSION['AlreadySent'])) { $temp_mem = load_member($e['MemberID'], $list_details['ListID']); log_mailing_error(DisplayDate(time()) . ',' . $temp_mem['Email'] . ',' . 'Already received in this run'); $qry = "UPDATE " . $TABLEPREFIX . "send_recipients SET Problems='1' WHERE MemberID='".addslashes($e['MemberID'])."' AND SendID='".addslashes($SendID)."'"; $queries_to_run[] = $qry; continue; } $_SESSION['AlreadySent'][] = $e['MemberID']; $qry = "UPDATE " . $TABLEPREFIX . "sends_perhour set EmailsSent=EmailsSent+1, HourEnded='".addslashes($SYSTEMTIME)."' WHERE SendID='".addslashes($SendID)."'"; $queries_to_run[] = $qry; $problem_query = "DELETE FROM " . $TABLEPREFIX . "send_recipients WHERE MemberID='".addslashes($e['MemberID'])."' AND SendID='".addslashes($SendID)."'"; if($e['MemberID']>0) { //send the email! $TheEmail = CreateEmail($SendID, $e['MemberID'], $e['Format'], $send); if (!$TheEmail) { $skip = true; if ($e['Format'] == 2) { $TheEmail = CreateEmail($SendID, $e['MemberID'], 1, $send); if (isset($TheEmail['Body']) && $TheEmail['Body'] != '') { $skip = false; } } if ($skip) { // this will stop blank emails being sent to text subscribers if you send a html newsletter.. $queries_to_run[] = $problem_query; $temp_mem = load_member($e['MemberID'], $list_details['ListID']); log_mailing_error(DisplayDate(time()) . ',' . $temp_mem['Email'] . ',' . 'Subscriber would have received a blank email (subscribed to receive ' . (($e['Format'] == 2) ? 'HTML' : 'TEXT') . ')'); continue; } } $TheEmail = stripslashes_array($TheEmail); if (Banned($TheEmail['Email'], $send['ListID'])) { log_mailing_error(DisplayDate(time()) . ',' . $TheEmail['Email'] . ',' . 'Email address (or domain) is banned from the mailing list'); $queries_to_run[] = $problem_query; continue; } $subject = EmailBody('0', $e['MemberID'], $e['Format'], $TheEmail['Subject'], array(), $send['ListID']); if ($TheEmail['Email']) { // if they are using a specific server, use the SendEmail function... if ($CURRENTADMIN['EmailServer'] != '') { $emailmsg = "To: " . $TheEmail['Email'] . "\n" . "Subject: " . $subject . "\n" . $TheEmail['Headers'] . "\n" . $TheEmail['Body']; list($email_result, $servermsg) = SendEmail($TheEmail['Email'], $TheEmail['ReturnPath'], $emailmsg, $CURRENTADMIN['EmailServer'], $CURRENTADMIN['EmailServerPort']); } // if there is no email server set, then use the internal php function. if (!isset($CURRENTADMIN['EmailServer']) || $CURRENTADMIN['EmailServer'] == '') { if (SAFE_MODE) { $email_result = mail($TheEmail['Email'], $subject, $TheEmail['Body'], $TheEmail['Headers']); } else { $email_result = mail($TheEmail['Email'], $subject, $TheEmail['Body'], $TheEmail['Headers'], '-f' . $TheEmail['ReturnPath']); } } if ($email_result) { $qry = "DELETE FROM " . $TABLEPREFIX . "send_recipients WHERE SendID='".addslashes($SendID)."' AND MemberID='".addslashes($e['MemberID'])."'"; $queries_to_run[] = $qry; // 1 = text // 2 = html. if($e['Format'] == 1) { $s=", TextRecipients=TextRecipients+1"; } else { $s=", HTMLRecipients=HTMLRecipients+1"; } $qry = "UPDATE " . $TABLEPREFIX . "sends SET EmailsSent=EmailsSent+1 $s WHERE SendID='".addslashes($SendID)."'"; $queries_to_run[] = $qry; //time taken so far! $time_end = getmicrotime(); $time = round($time_end - $time_start,2); } else { $logmsg = 'Unable to Email'; if ($servermsg) $logmsg .= ': ' . $servermsg; log_mailing_error(DisplayDate(time()) . ',' . $TheEmail['Email'] . ',' . $logmsg); $queries_to_run[] = $problem_query; } } else { log_mailing_error(DisplayDate(time()) . ',' . $TheEmail['Email'] . ',' . 'Unable to find email address for subscriber'); $queries_to_run[] = $problem_query; } } else { log_mailing_error(DisplayDate(time()) . ',' . $TheEmail['Email'] . ',' . 'MemberID < 0! Notify System Administrator'); } } foreach($queries_to_run as $qry) { mysql_query($qry); } sleep($PAUSE); } } # end if (page == dosending) $refresh_link = MakeAdminLink("send?SendID=$SendID&Action=DoSending&PageID=DoSending&newsletter_archives=$ser_newsletter_archives&StartTime=$StartTime&random=" . getmicrotime()); ?>