$attach_name) { $attachments[$attach_name] = file_get_contents("$BASEDIR/attachments/$attach_name"); } // Sets bounce back email if not already set if (!$bounceReply) $bounceReply = $ReplyTo; // Now send the email if (SendEmail($email, $ReplyTo, $EmailSubject, $Message, $ReplyDescription, '', $attachments, $bounceReply)) { $status = "Sent"; $sent++; } else { $status = "Error"; $errors++; // Update the record status if there is an error $query = "update email_send_log " . "set status = 'Error' " . "where email_log_id = '$log_id' " . "and email = '$email'"; mysql_query($query); } } } // // Update the header record with the stats from this run // $query = "update email_header " . "set processed_records = processed_records + $count, " . "sent_successfully = sent_successfully + $sent, " . "skipped = skipped + $skipped, " . "errors = errors + $errors " . "where record_num = '$log_id'"; mysql_query($query); // // Determine if the batch is complete // $query = "select * from email_header " . "where record_num = '$log_id'"; $results = mysql_query($query); $header = mysql_fetch_array($results); $matching = $header[matching_records]; $processed = $header[processed_records]; } if ($number == 0 || $matching == $processed) { // // If there are no more records to process then close the batch // $query = "update email_header " . "set completed = now(), " . "status = 'completed' " . "where record_num = '$log_id'"; mysql_query($query); } } } } ?>