3 final class PhabricatorMailManagementShowInboundWorkflow
4 extends PhabricatorMailManagementWorkflow
{
6 protected function didConstruct() {
8 ->setName('show-inbound')
9 ->setSynopsis(pht('Show diagnostic details about inbound mail.'))
11 '**show-inbound** --id 1 --id 2')
17 'help' => pht('Show details about inbound mail with given ID.'),
23 public function execute(PhutilArgumentParser
$args) {
24 $console = PhutilConsole
::getConsole();
26 $ids = $args->getArg('id');
28 throw new PhutilArgumentUsageException(
30 "Use the '%s' flag to specify one or more messages to show.",
34 $messages = id(new PhabricatorMetaMTAReceivedMail())->loadAllWhere(
39 $ids = array_fuse($ids);
40 $missing = array_diff_key($ids, $messages);
42 throw new PhutilArgumentUsageException(
44 'Some specified messages do not exist: %s',
45 implode(', ', array_keys($missing))));
49 $last_key = last_key($messages);
50 foreach ($messages as $message_key => $message) {
53 $info[] = pht('PROPERTIES');
54 $info[] = pht('ID: %d', $message->getID());
55 $info[] = pht('Status: %s', $message->getStatus());
56 $info[] = pht('Related PHID: %s', $message->getRelatedPHID());
57 $info[] = pht('Author PHID: %s', $message->getAuthorPHID());
58 $info[] = pht('Message ID Hash: %s', $message->getMessageIDHash());
60 if ($message->getMessage()) {
62 $info[] = pht('MESSAGE');
63 $info[] = $message->getMessage();
67 $info[] = pht('HEADERS');
68 foreach ($message->getHeaders() as $key => $value) {
69 if (is_array($value)) {
70 $value = implode("\n", $value);
72 $info[] = pht('%s: %s', $key, $value);
75 $bodies = $message->getBodies();
77 $last_body = last_key($bodies);
80 $info[] = pht('BODIES');
81 foreach ($bodies as $key => $value) {
82 $info[] = pht('Body "%s"', $key);
84 if ($key != $last_body) {
89 $attachments = $message->getAttachments();
92 $info[] = pht('ATTACHMENTS');
94 $info[] = pht('No attachments.');
96 foreach ($attachments as $attachment) {
97 $info[] = pht('File PHID: %s', $attachment);
101 $console->writeOut("%s\n", implode("\n", $info));
103 if ($message_key != $last_key) {
104 $console->writeOut("\n%s\n\n", str_repeat('-', 80));