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(); $headers .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7"; 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, $subject, $message) == false) { echo "[fail: " . $email->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() { } } ?>