From 78a0f0a00650c9a5e3c4d4cadcacc409919067ea Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 26 Feb 2010 16:12:36 +0000 Subject: Add pressrelease module. Make lots of codesharing with the newsletter module. --- utils/mail.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'utils/mail.php') diff --git a/utils/mail.php b/utils/mail.php index 866bad4..e681d21 100644 --- a/utils/mail.php +++ b/utils/mail.php @@ -22,4 +22,72 @@ class Email { } } +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; + $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) { + + $this->postSingle($email, $ubject, $message); + + $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() + { + } +} + ?> \ No newline at end of file -- cgit v1.2.3