00001 <?php
00002
00015
00016
00017
00018 import ('mail.MailTemplate');
00019
00020 class MassMail extends MailTemplate {
00021 var $callback;
00022 var $frequency;
00023
00027 function MassMail($emailKey = null, $locale = null, $enableAttachments = null, $journal = null) {
00028 parent::MailTemplate($emailKey, $locale, $enableAttachments, $journal);
00029 $this->callback = null;
00030 $this->frequency = 10;
00031 }
00032
00039 function setCallback(&$callback) {
00040 $this->callback =& $callback;
00041 }
00042
00047 function setFrequency($frequency) {
00048 $this->frequency = $frequency;
00049 }
00050
00055 function send() {
00056 @set_time_limit(0);
00057
00058 $realRecipients = $this->getRecipients();
00059 $realSubject = $this->getSubject();
00060 $realBody = $this->getBody();
00061
00062 $index = 0;
00063 $success = true;
00064 $max = count($realRecipients);
00065 foreach ($realRecipients as $recipient) {
00066 $this->clearAllRecipients();
00067
00068 $this->addRecipient($recipient['email'], $recipient['name']);
00069 $this->setSubject($realSubject);
00070 $this->setBody($realBody);
00071
00072 $success = $success && MailTemplate::send(false);
00073 $index++;
00074 if ($this->callback && ($index % $this->frequency) == 0) call_user_func($this->callback, $index, $max);
00075 }
00076 $this->setRecipients($realRecipients);
00077 return $success;
00078 }
00079 }
00080
00081 ?>