Esempio n. 1
0
 /**
  * @return Mailer
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 2
0
 public static function getInstance($subject = "")
 {
     if (self::$instance === false) {
         self::$instance = new Mailer($subject);
     }
     return self::$instance;
 }
Esempio n. 3
0
 /**
  * Mailer::instance()
  * 
  * @return
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new Mailer();
     }
     return self::$instance;
 }
Esempio n. 4
0
 public function actionRunat()
 {
     //首先,找出当前时间之前的没有运行的at任务
     $ats = AtModel::instance()->getShouldRun();
     foreach ($ats as $at) {
         if (Mailer::instance()->sendMail($at['title'], $at['content'], $at['email'])) {
             AtModel::instance()->update($at['id'], array('hasrun' => 1));
         }
     }
 }
 public function actionRuncron()
 {
     $todayDay = date('Y-m-d');
     $crons = CronModel::instance()->getShowRun();
     foreach ($crons as $cron) {
         if (Mailer::instance()->sendMail($cron['title'], $cron['content'], $cron['email'])) {
             CronModel::instance()->update($cron['id'], array('last_run_date' => $todayDay));
         }
     }
 }
Esempio n. 6
0
 protected function send()
 {
     $mailer = Mailer::instance();
     $mailer->service->setSubject($this->subject)->setFrom($this->sender)->setBody(nl2br($this->message, false))->setAttachments($this->attachments);
     if ($this->useBcc == true) {
         $mailer->service->setBcc($this->recipient);
     } else {
         $mailer->service->setTo($this->recipient);
     }
     $this->reset();
     $mailer->service->send();
 }
Esempio n. 7
0
 public static function create()
 {
     $args = func_get_args();
     if (empty($args)) {
         throw new Exception('Mailer : mail method required.');
         // pas top comme msg
     }
     $methodName = $args[0];
     unset($args[0]);
     // PHP5 ne gère pas bien l'héritage de fonctions statiques, aussi sommes-nous
     // obligés de préciser que nous voulons instancier la classe ApplicationMailer.
     // Cela contraint l'user à nommer sa classe ApplicationMailer...
     if (self::$instance == null) {
         self::$instance = new ApplicationMailer($methodName);
     }
     // appel de la méthode définie par l'user
     call_user_func_array(array(self::$instance, $methodName), $args);
     if (!is_string(self::$instance->body)) {
     }
 }
Esempio n. 8
0
 public static function sendMail($subject = '', $body = '', $to = array(), $cc = array(), $bcc = array(), $att = array())
 {
     try {
         self::$instance = new Mailer();
         self::$instance->addSubject($subject);
         self::$instance->addBody($body);
         self::$instance->addTo($to);
         if (!empty($cc)) {
             self::$instance->addCopy($cc);
         }
         if (!empty($bcc)) {
             self::$instance->addBackCopy($bcc);
         }
         if (!empty($att)) {
             self::$instance->addAttach($att);
         }
         return self::$instance->send();
     } catch (phpmailerException $e) {
         self::throwMailerException($e->getMessage());
         return false;
     }
 }