function startup(&$controller) { $result = parent::startup($controller); $iniFile = APP . 'plugins' . DS . 'form_mail' . DS . 'config' . DS . 'smtp.ini.php'; $params = parse_ini_file($iniFile); if ($params) { $this->smtp(true); $this->smtpServer($params); } return $result; }
private function __send($to, $subject, $template = 'default') { $qdmail = new QdmailComponent(null); $qdmail->startup($this->controller); config('mail'); $params = MAIL_CONFIG::$smtp; $qdmail->smtp(true); $qdmail->smtpServer($params); //$qdmail->debug(2); $qdmail->to($to); $qdmail->from($params['from']); $qdmail->subject($subject); $this->controller->view = 'View'; $qdmail->cakeText(null, $template, null, null, 'iso-2022-jp'); return $qdmail->send(); }
private function __sendPosts($count) { $qdmail = new QdmailComponent(null); $qdmail->startup($this->controller); $sended = 0; for ($i = 0; $i < $count; $i++) { $conditions = $this->__sqlNoCache($this->postConditions); $offset = $i; $post = $this->Post->find('first', compact('conditions', 'offset')); $success = $this->__sendUsers($qdmail, $post); if ($success) { $this->Post->modifySended($post['Post']['id']); } $sended += $success; } $this->out(sprintf('Sended total %s mails.', $sended)); CakeLog::write('sendmail', sprintf('Send Finsh!!! total %s mails.', intval($count), $sended)); return $sended; }