Example #1
0
 /**
  * Return a textual error message for a MDB error code
  *
  * @param   int     $value error code
  * @return  string  error message, or false if the error code was
  *                  not recognized
  * @access public
  */
 function errorMessage($value)
 {
     static $errorMessages;
     if (!isset($errorMessages)) {
         $errorMessages = array(MAILQUEUE_ERROR => 'unknown error', MAILQUEUE_ERROR_NO_DRIVER => 'No mail driver specified', MAILQUEUE_ERROR_NO_CONTAINER => 'No container specified', MAILQUEUE_ERROR_CANNOT_INITIALIZE => 'Cannot initialize container', MAILQUEUE_ERROR_NO_OPTIONS => 'No container options specified', MAILQUEUE_ERROR_CANNOT_CONNECT => 'Cannot connect to database', MAILQUEUE_ERROR_QUERY_FAILED => 'db query failed', MAILQUEUE_ERROR_UNEXPECTED => 'Unexpected class', MAILQUEUE_ERROR_CANNOT_SEND_MAIL => 'Cannot send email');
     }
     if (Mail_Queue::isError($value)) {
         $value = $value->getCode();
     }
     return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[MAILQUEUE_ERROR];
 }
Example #2
0
File: mdb.php Project: Blu2z/implsk
 /**
  * Preload mail to queue.
  *
  * @return mixed   True on success else Mail_Queue_Error object.
  * @access private
  */
 function _preload()
 {
     $query = 'SELECT id FROM ' . $this->mail_table . ' WHERE sent_time IS NULL AND try_sent < ' . $this->try . ' AND time_to_send < ' . $this->db->getTimestampValue(date("Y-m-d H:i:s")) . ' ORDER BY time_to_send';
     $res = $this->db->limitQuery($query, null, $this->offset, $this->limit);
     if (MDB::isError($res)) {
         return new Mail_Queue_Error(MAILQUEUE_ERROR_QUERY_FAILED, $this->pearErrorMode, E_USER_ERROR, __FILE__, __LINE__, 'MDB: query failed - "' . $query . '" - ' . $res->getMessage());
     }
     $this->_last_item = 0;
     $this->queue_data = array();
     //reset buffer
     while ($row = $this->db->fetchInto($res, MDB_FETCHMODE_ASSOC)) {
         $this->queue_data[$this->_last_item] = $this->getMailById($row['id']);
         if (Mail_Queue::isError($this->queue_data[$this->_last_item])) {
             return $this->queue_data[$this->_last_item];
         }
         $this->_last_item++;
     }
     @$this->db->freeResult($res);
     return true;
 }
Example #3
0
 /**
  * Preload mail to queue.
  * The buffer size can be set in the options.
  *
  * @return mixed True on success, false when the limit is met, else
  *               Mail_Queue_Error object.
  *
  * @access private
  */
 function preload()
 {
     if (!empty($this->queue_data)) {
         return true;
     }
     if (!$this->limit) {
         return false;
         //limit reached
     }
     $bkp_limit = $this->limit;
     //set buffer size
     if ($bkp_limit == MAILQUEUE_ALL) {
         $this->limit = $this->buffer_size;
     } else {
         $this->limit = min($this->buffer_size, $this->limit);
     }
     if (Mail_Queue::isError($err = $this->_preload())) {
         return $err;
     }
     //restore limit
     if ($bkp_limit == MAILQUEUE_ALL) {
         $this->limit = MAILQUEUE_ALL;
     } else {
         $this->limit = $bkp_limit - count($this->queue_data);
     }
     //set buffer pointers
     $this->_current_item = 0;
     $this->_last_item = count($this->queue_data) - 1;
     return true;
 }