From ffcfc0465226a3cdb78c247f89d7590b7b4987fa Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 22 Feb 2018 10:09:49 -0800 Subject: [PATCH] Add some delivery diagnostic headers to outbound mail Summary: Fixes T13087. Ref T13090. An install ran into a situation where mail was being double-delivered, and it wasn't immediately clear where in the pipeline the issue lay. This change adds some headers which should rule out (or, at least, render very unlikely) some possible causes if we encounter similar issues in the future. The `X-Phabricator-Mail-ID` header stores the ID of the `MetaMTAMail` storage object so we can distinguish between two messages sent to two different targets and one message which may have been split or re-sent. It also makes it easier to know what to `bin/mail show-outbound --id ` and where to find the message in the web UI for additional information. The `X-Phabricator-Send-Attempt` is a unique value per attempt. If two mail messages are delivered with the same attempt value, the split is probably downstream from Phabricator. If they have different attempt values, the split is probably in Phabricator. (In this case, the split was somewhere downstream from us, since sending mail with `/usr/bin/mail` also resulted in duplicates.) Test Plan: Send some mail, inspected it with `bin/mail show-outbound --id `, saw new headers with sensible/expected values. Maniphest Tasks: T13090, T13087 Differential Revision: https://secure.phabricator.com/D19124 --- .../metamta/storage/PhabricatorMetaMTAMail.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index 9dfd6a3eb6..5326e10639 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -1302,6 +1302,11 @@ final class PhabricatorMetaMTAMail $headers[] = array('Thread-Topic', $related_phid); } + $headers[] = array('X-Phabricator-Mail-ID', $this->getID()); + + $unique = Filesystem::readRandomCharacters(16); + $headers[] = array('X-Phabricator-Send-Attempt', $unique); + return $headers; } @@ -1356,6 +1361,8 @@ final class PhabricatorMetaMTAMail 'X-Phabricator-Sent-This-Message', 'X-Phabricator-Must-Encrypt', + 'X-Phabricator-Mail-ID', + 'X-Phabricator-Send-Attempt', ); // NOTE: The major header we want to drop is "X-Phabricator-Mail-Tags". -- 2.51.2