diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-23 20:43:51 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-23 20:43:51 -0400 |
commit | 8314c99b56e66c2b86dd32432bcf5ed94a3ece02 (patch) | |
tree | 564ed1c270a0907efb5be8da1d971526cd235c6e /app/Core/Mail | |
parent | dc6176fca23ea697380ab115aea976fa8271f047 (diff) |
Added QueueManager to process background jobs
Diffstat (limited to 'app/Core/Mail')
-rw-r--r-- | app/Core/Mail/Client.php | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/app/Core/Mail/Client.php b/app/Core/Mail/Client.php index 641b6abe..44f4753a 100644 --- a/app/Core/Mail/Client.php +++ b/app/Core/Mail/Client.php @@ -2,6 +2,7 @@ namespace Kanboard\Core\Mail; +use Kanboard\Job\EmailJob; use Pimple\Container; use Kanboard\Core\Base; @@ -46,23 +47,29 @@ class Client extends Base public function send($email, $name, $subject, $html) { if (! empty($email)) { - $this->logger->debug('Sending email to '.$email.' ('.MAIL_TRANSPORT.')'); - - $start_time = microtime(true); - $author = 'Kanboard'; + $this->queueManager->push(EmailJob::getInstance($this->container) + ->withParams($email, $name, $subject, $html, $this->getAuthor()) + ); + } - if ($this->userSession->isLogged()) { - $author = e('%s via Kanboard', $this->helper->user->getFullname()); - } + return $this; + } - $this->getTransport(MAIL_TRANSPORT)->sendEmail($email, $name, $subject, $html, $author); + /** + * Get email author + * + * @access public + * @return string + */ + public function getAuthor() + { + $author = 'Kanboard'; - if (DEBUG) { - $this->logger->debug('Email sent in '.round(microtime(true) - $start_time, 6).' seconds'); - } + if ($this->userSession->isLogged()) { + $author = e('%s via Kanboard', $this->helper->user->getFullname()); } - return $this; + return $author; } /** |