@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorMetaMTAWorker
4 extends PhabricatorWorker {
5
6 public function getMaximumRetryCount() {
7 return 250;
8 }
9
10 public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
11 return ($task->getFailureCount() * 15);
12 }
13
14 protected function doWork() {
15 $message = $this->loadMessage();
16
17 if ($message->getStatus() != PhabricatorMailOutboundStatus::STATUS_QUEUE) {
18 return;
19 }
20
21 try {
22 $message->sendNow();
23 } catch (PhabricatorMetaMTAPermanentFailureException $ex) {
24 // If the mailer fails permanently, fail this task permanently.
25 throw new PhabricatorWorkerPermanentFailureException($ex->getMessage());
26 }
27 }
28
29 private function loadMessage() {
30 $message_id = $this->getTaskData();
31 $message = id(new PhabricatorMetaMTAMail())
32 ->load($message_id);
33
34 if (!$message) {
35 throw new PhabricatorWorkerPermanentFailureException(
36 pht(
37 'Unable to load mail message (with ID "%s") while preparing to '.
38 'deliver it.',
39 $message_id));
40 }
41
42 return $message;
43 }
44
45 public function renderForDisplay(PhabricatorUser $viewer) {
46 return phutil_tag(
47 'pre',
48 array(),
49 PlatformSymbols::getPlatformServerPath().
50 ' $ ./bin/mail show-outbound --id '.
51 $this->getTaskData());
52 }
53
54}