Ejemplo n.º 1
0
 public function do_execute()
 {
     $mailing = \thebuggenie\core\framework\Context::getModule('mailing');
     if (!$mailing->isOutgoingNotificationsEnabled()) {
         $this->cliEcho("Outgoing email notifications are disabled.\n", 'red', 'bold');
         $this->cliEcho("\n");
         return;
     }
     if (!$mailing->getMailingUrl()) {
         $this->cliEcho("You must configure the mailing url via the web interface before you can use this feature.\n", 'red', 'bold');
         $this->cliEcho("\n");
         return;
     }
     $this->cliEcho("Processing mail queue ... \n", 'white', 'bold');
     $limit = $this->getProvidedArgument('limit', null);
     $messages = MailQueueTable::getTable()->getQueuedMessages($limit);
     $this->cliEcho("Email(s) to process: ");
     $this->cliEcho(count($messages) . "\n", 'white', 'bold');
     if ($this->getProvidedArgument('test', 'no') == 'no') {
         if (count($messages) > 0) {
             $processed_messages = array();
             $failed_messages = 0;
             try {
                 foreach ($messages as $message_id => $message) {
                     $retval = $mailing->getMailer()->send($message);
                     $processed_messages[] = $message_id;
                     if (!$retval) {
                         $failed_messages++;
                     }
                 }
             } catch (\Exception $e) {
                 throw $e;
             }
             if (count($processed_messages)) {
                 MailQueueTable::getTable()->deleteProcessedMessages($processed_messages);
                 $this->cliEcho("Emails successfully processed: ");
                 $this->cliEcho(count($messages) . "\n", 'green', 'bold');
                 if ($failed_messages > 0) {
                     $this->cliEcho("Emails processed with error(s): ");
                     $this->cliEcho($failed_messages . "\n", 'red', 'bold');
                 }
             }
         }
     } else {
         $this->cliEcho("Not processing queue...\n");
     }
 }
Ejemplo n.º 2
0
 public function sendMail(Swift_Message $email)
 {
     if ($this->isOutgoingNotificationsEnabled()) {
         if ($this->usesEmailQueue()) {
             MailQueueTable::getTable()->addMailToQueue($email);
             return true;
         } else {
             $retval = $this->mail($email);
         }
         return $retval;
     }
 }
Ejemplo n.º 3
0
 protected function _upgradeFrom4dot1dot2(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\modules\mailing\entities\tables\MailQueueTable::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_412\MailQueueTable::getTable());
     $this->upgrade_complete = true;
     $this->current_version = '4.1.3';
 }