diff --git a/conf/default.conf.php b/conf/default.conf.php index 9c973f6f13..c287485432 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -279,6 +279,15 @@ return array( // address will be stored in an 'From Email' field on the task. 'metamta.maniphest.default-public-author' => null, + // If this option is enabled, Phabricator will add a "Precedence: bulk" + // header to transactional mail (e.g., Differential, Maniphest and Herald + // notifications). This may improve the behavior of some auto-responder + // software and prevent it from replying. However, it may also cause + // deliverability issues -- notably, you currently can not send this header + // via Amazon SES, and enabling this option with SES will prevent delivery + // of any affected mail. + 'metamta.precedence-bulk' => false, + // -- Auth ------------------------------------------------------------------ // diff --git a/src/applications/differential/mail/base/DifferentialMail.php b/src/applications/differential/mail/base/DifferentialMail.php index ea898bed4c..c298f533c3 100644 --- a/src/applications/differential/mail/base/DifferentialMail.php +++ b/src/applications/differential/mail/base/DifferentialMail.php @@ -106,6 +106,7 @@ abstract class DifferentialMail { $template->addHeader('X-Herald-Rules', $this->heraldRulesHeader); } + $template->setIsBulk(true); $template->setRelatedPHID($this->getRevision()->getPHID()); $phids = array(); diff --git a/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php index c43f85ed39..1674a31f61 100644 --- a/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php @@ -254,6 +254,7 @@ class ManiphestTransactionEditor { ->addHeader('Thread-Topic', 'Maniphest Task '.$task->getID()) ->setThreadID($thread_id, $is_create) ->setRelatedPHID($task->getPHID()) + ->setIsBulk(true) ->setBody($body); $mails = $reply_handler->multiplexMail( diff --git a/src/applications/metamta/controller/send/PhabricatorMetaMTASendController.php b/src/applications/metamta/controller/send/PhabricatorMetaMTASendController.php index 8b971b878f..0f865d7928 100644 --- a/src/applications/metamta/controller/send/PhabricatorMetaMTASendController.php +++ b/src/applications/metamta/controller/send/PhabricatorMetaMTASendController.php @@ -32,6 +32,7 @@ class PhabricatorMetaMTASendController extends PhabricatorMetaMTAController { $mail->setFrom($request->getUser()->getPHID()); $mail->setSimulatedFailureCount($request->getInt('failures')); $mail->setIsHTML($request->getInt('html')); + $mail->setIsBulk($request->getInt('bulk')); $mail->save(); if ($request->getInt('immediately')) { $mail->sendNow(); @@ -110,6 +111,10 @@ class PhabricatorMetaMTASendController extends PhabricatorMetaMTAController { id(new AphrontFormCheckboxControl()) ->setLabel('HTML') ->addCheckbox('html', '1', 'Send as HTML email.')) + ->appendChild( + id(new AphrontFormCheckboxControl()) + ->setLabel('Bulk') + ->addCheckbox('bulk', '1', 'Send with bulk email headers.')) ->appendChild( id(new AphrontFormCheckboxControl()) ->setLabel('Send Now') diff --git a/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php index c8f59a91b3..0ffd7017e1 100644 --- a/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php @@ -151,6 +151,20 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { return $this; } + /** + * Flag that this is an auto-generated bulk message and should have bulk + * headers added to it if appropriate. Broadly, this means some flavor of + * "Precedence: bulk" or similar, but is implementation and configuration + * dependent. + * + * @param bool True if the mail is automated bulk mail. + * @return this + */ + public function setIsBulk($is_bulk) { + $this->setParam('is-bulk', $is_bulk); + return $this; + } + /** * Use this method to set an ID used for message threading. MetaMTA will * set appropriate headers (Message-ID, In-Reply-To, References and @@ -315,6 +329,13 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { $mailer->setIsHTML(true); } break; + case 'is-bulk': + if ($value) { + if (PhabricatorEnv::getEnvConfig('metamta.precedence-bulk')) { + $mailer->addHeader('Precedence', 'bulk'); + } + } + break; case 'thread-id': if ($is_first && $mailer->supportsMessageIDHeader()) { $mailer->addHeader('Message-ID', $value); diff --git a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php index ece3ca535f..3ba9992f49 100644 --- a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php @@ -127,6 +127,7 @@ EOBODY; $mailer->addTos($email_phids); $mailer->setSubject($subject); $mailer->setBody($body); + $mailer->setIsBulk(true); $mailer->addHeader('X-Herald-Rules', $xscript->getXHeraldRulesHeader()); if ($author_phid) {