Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/metamta/PhabricatorMetaMTAWorker.php
12249 views
1
<?php
2
3
final 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
),
50
'phabricator/ $ ./bin/mail show-outbound --id '.$this->getTaskData());
51
}
52
53
}
54
55