function send_mail(&$smtp, $website, $id, $email, $order, $updatefile) { global $test; $hash = id_encode($id); $subject = $_SESSION['subject']; $emailfrom = $_SESSION['emailfrom']; $htmlemail = $_SESSION['htmlemail']; $emailname = $_SESSION['emailname'] . "<{$emailfrom}>"; $bounce = $_SESSION['bounce']; $text = $_SESSION['body']; $goto = $website . $updatefile; if ($updatefile != "none") { if ($htmlemail == 1) { $text .= "<br>_____________________________________________________<br>"; $text .= "To unsubscribe or update your listing <a href=\"" . $goto . "?id={$id}&token=" . $hash . "\">click here</a> "; } else { $text .= "\n_____________________________________________________\n"; $text .= "To unsubscribe or update your listing go to:\n "; $text .= $goto . "?id={$id}&token=" . $hash; } } if (!$test) { //glog("compose $email"); $headers = "From: {$emailname}\r\n"; $headers .= "Reply-To: {$emailfrom}\r\n"; $headers .= "X-Sender: {$emailfrom}\r\n"; if ($htmlemail == 1) { $headers .= "Content-Type: text/html\r\n"; } $headers .= "Return-Path: {$bounce}\r\n"; $ok = $smtp->email($bounce, $email, '', $headers, $subject, $text); //mail($email, stripslashes($subject), stripslashes($text), $headers); if ($ok) { //glog(" sent $email id=$id order=$order ok=" . ($ok ? 'TRUE' : 'FALSE') ); echo "sent {$email}<br>"; return true; } else { //glog("error $email id=$id order=$order ok=" . ($ok ? 'TRUE' : 'FALSE') ); if (function_exists('glog')) { glog(" smtp_client error: " . $smtp->msg); } echo "error sending {$email} ({$smtp->msg})<br>"; return false; } } else { echo "test {$email}<br>"; return true; } }
function test_process(&$offset, $chunk_size) { $_SESSION['max_count'] = 800; $i = $offset; $stop = $i + $chunk_size; while ($i < $stop) { if ($i > 799) { return false; } usleep(100000); $data = "{$i} -- " . date("D M j G:i:s T Y"); glog($data); echo "<br>{$data}\n"; $offset = $i + 1; flush(); $i++; } return 'success'; }