getTaskData(); $this->message = id(new PhabricatorMetaMTAMail())->loadOneWhere( 'id = %d', $this->getTaskData()); if (!$this->message) { return null; } $lease_duration = max($this->message->getNextRetry() - time(), 0) + 15; return $lease_duration; } public function doWork() { $message = $this->message; if (!$message || $message->getStatus() != PhabricatorMetaMTAMail::STATUS_QUEUE) { return; } $id = $message->getID(); $message->sendNow(); // task failed if the message is still queued // (instead of sent, void, or failed) if ($message->getStatus() == PhabricatorMetaMTAMail::STATUS_QUEUE) { throw new Exception('Failed to send message'); } } }