Exemple #1
0
 /**
  * @param int $limit
  */
 public static function processQueue($limit)
 {
     $limit = (int) $limit;
     $result = CM_Db_Db::execRead('SELECT * FROM `cm_mail` ORDER BY `createStamp` LIMIT ' . $limit);
     while ($row = $result->fetch()) {
         $mail = new CM_Mail();
         foreach (unserialize($row['to']) as $to) {
             $mail->addTo($to['address'], $to['name']);
         }
         foreach (unserialize($row['replyTo']) as $replyTo) {
             $mail->addReplyTo($replyTo['address'], $replyTo['name']);
         }
         foreach (unserialize($row['cc']) as $cc) {
             $mail->addCc($cc['address'], $cc['name']);
         }
         foreach (unserialize($row['bcc']) as $bcc) {
             $mail->addBcc($bcc['address'], $bcc['name']);
         }
         if ($headerList = unserialize($row['customHeaders'])) {
             foreach ($headerList as $label => $valueList) {
                 foreach ($valueList as $value) {
                     $mail->addCustomHeader($label, $value);
                 }
             }
         }
         $sender = unserialize($row['sender']);
         $mail->setSender($sender['address'], $sender['name']);
         $mail->_send($row['subject'], $row['text'], $row['html']);
         CM_Db_Db::delete('cm_mail', array('id' => $row['id']));
     }
 }