email = $email; $this->timestamp = $timestamp; } public function send($subject, $message, $sender, $replyto) { $headers = "From: " . $sender . "\r\n"; $headers .= "Reply-To: " . $replyto . "\r\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n"; $headers .= "X-Mailer: PHP/" . phpversion(); return mail($this->email, utf8_decode($subject), utf8_decode($message), $headers); } } class _Mailinglist { public $mailinglist = array(); public $subj_prefix; public $sender; public $replyto; public $footer; public function add($email) { $key = $email->email; if(array_key_exists($key, $this->mailinglist)) return false; $this->mailinglist[$key] = $email; return true; } public function remove($email) { if(array_key_exists($email, $this->mailinglist)) { unset($this->mailinglist[$email]); return true; } return false; } public function postSingle($email, $subject, $message) { $subject = "[".$this->subj_prefix."] " . $subject; $message .= "\n\n".$this->footer; return $email->send($subject, $message, $this->sender, $this->replyto); } public function post($subject, $message) { $sz = sizeof($this->mailinglist); echo "
Sending ". $sz ." mails
\n<"; ob_flush(); flush(); $num = 0; $lvl = 0; $steps = floor($sz / 10) + 1; foreach($this->mailinglist as $email) { if($this->postSingle($email, $ubject, $message) == false) { echo "[fail: " . $email . "]"; } $pct = $num / $sz * 100; if($pct >= $lvl) { printf("%.0f%%", $lvl); $lvl += 100/$steps; } else { echo "."; } ob_flush(); flush(); $num++; } echo "[100%]>\n
done
\n"; echo "[CLOSE]"; echo "
\n"; ob_flush(); flush(); } public function _Mailinglist() { } } ?>