Example #1
0
 public function execute($lastRunDt = null)
 {
     $eq = new Ot_Model_DbTable_EmailQueue();
     $messages = $eq->getWaitingEmails(20);
     $logger = Zend_Registry::get('logger');
     foreach ($messages as $m) {
         try {
             $m['zendMailObject']->send();
             $m['status'] = 'sent';
             $m['sentDt'] = time();
         } catch (Exception $e) {
             $m['status'] = 'error';
         }
         $where = $eq->getAdapter()->quoteInto('queueId = ?', $m['queueId']);
         $eq->update($m, $where);
         $logOptions = array('attributeName' => 'queueId', 'attributeId' => $m['queueId']);
         $logger->setEventItem('attributeName', 'queueId');
         $logger->setEventItem('attributeId', $m['queueId']);
         $logger->log('Mail Sent', Zend_Log::INFO);
     }
 }
 /**
  * Deletes an email from the queue
  */
 public function deleteAction()
 {
     $eq = new Ot_Model_DbTable_EmailQueue();
     $queueId = $this->_getParam('queueId', null);
     if (is_null($queueId)) {
         throw new Ot_Exception_Input('msg-error-queueIdNotSet');
     }
     $email = $eq->find($queueId);
     if (is_null($email)) {
         throw new Ot_Exception_Data('msg-error-noQueue');
     }
     if ($this->_request->isPost()) {
         $where = $eq->getAdapter()->quoteInto('queueId = ?', $queueId);
         $eq->delete($where);
         $this->_helper->messenger->addSuccess('ot-emailqueue-delete:success');
         $this->_helper->redirector->gotoRoute(array('controller' => 'emailqueue'), 'ot', true);
     } else {
         throw new Ot_Exception_Access('You are not allowed to access this method directly');
     }
 }