public function do_execute() { $mailing = TBGContext::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 = TBGMailQueueTable::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) { // $mailer = $mailing->getMailer(); $processed_messages = array(); $failed_messages = 0; try { foreach ($messages as $message_id => $message) { $retval = $mailing->send($message); $processed_messages[] = $message_id; if (!$retval) { $failed_messages++; } } } catch (Exception $e) { throw $e; } if (count($processed_messages)) { TBGMailQueueTable::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"); } }
public function do_execute() { $this->cliEcho("Processing mail queue ... \n", 'white', 'bold'); $limit = $this->getProvidedArgument('limit', null); $messages = TBGMailQueueTable::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) { $mailer = TBGMailing::getModule()->getMailer(); $processed_messages = array(); $failed_messages = 0; try { foreach ($messages as $message_id => $message) { $retval = $mailer->send($message); $processed_messages[] = $message_id; if (!$retval) { $failed_messages++; } } } catch (Exception $e) { throw $e; } if (count($processed_messages)) { TBGMailQueueTable::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"); } }
public function sendMail(TBGMimemail $mail, $debug = false) { if ($this->isOutgoingNotificationsEnabled()) { if ($this->usesEmailQueue()) { TBGMailQueueTable::getTable()->addMailToQueue($mail); return true; } else { $mailer = $this->getMailer(); $retval = $mailer->send($mail); } return $retval; } }
public function sendMail(Swift_Message $email, $debug = false) { if ($this->isOutgoingNotificationsEnabled()) { if ($this->usesEmailQueue()) { TBGMailQueueTable::getTable()->addMailToQueue($email); return true; } else { $retval = $this->mail($email); } return $retval; } }