1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

Remove "metamta.domain" and "metamta.placeholder-to-recipient" config options

Summary:
Ref T920. This simplifies mail configuration.

The "metamta.domain" option is only used to generate Thread-ID values, and we just need something that looks like a bit like a domain in order to make GMail happy. Just use the install domain. In most cases, this is almost certainly the configured value anyway. In some cases, this may cause a one-time threading break for existing threads; I'll call this out in the changelog.

The "metamta.placeholder-to-recipient" is used to put some null value in "To:" when a mail only has CCs. This is so that if you write a local client mail rule like "when I'm in CC, burn the message in a fire" it works even if all the "to" addresses have elected not to receive the mail. Instead: just send it to an unlikely address at our own domain.

I'll add some additional handling for the possiblity that we may receive this email ourselves in the next change, but it overlaps with T7477.

Test Plan: Grepped for these configuration values.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T920

Differential Revision: https://secure.phabricator.com/D19942
This commit is contained in:
epriestley 2019-01-02 05:47:48 -08:00
parent afa69eedd1
commit a0668df75a
4 changed files with 25 additions and 28 deletions

View file

@ -380,6 +380,11 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
'Resource deflation is now managed automatically.'),
'celerity.minify' => pht(
'Resource minification is now managed automatically.'),
'metamta.domain' => pht(
'Mail thread IDs are now generated automatically.'),
'metamta.placeholder-to-recipient' => pht(
'Placeholder recipients are now generated automatically.'),
);
return $ancient_config;

View file

@ -139,13 +139,6 @@ actually works on your host, but if you haven't configured mail it may not be so
great. A number of other mailers are available (e.g., SES, SendGrid, SMTP,
custom mailers). This option is deprecated in favor of 'cluster.mailers'.
EODOC
));
$placeholder_description = $this->deformat(pht(<<<EODOC
When sending a message that has no To recipient (i.e. all recipients are CC'd),
set the To field to the following value. If no value is set, messages with no
To will have their CCs upgraded to To.
EODOC
));
$public_replies_description = $this->deformat(pht(<<<EODOC
@ -203,11 +196,6 @@ EODOC
'string',
'noreply@phabricator.example.com')
->setDescription(pht('Default "From" address.')),
$this->newOption(
'metamta.domain',
'string',
'phabricator.example.com')
->setDescription(pht('Domain used to generate Message-IDs.')),
$this->newOption(
'metamta.one-mail-per-recipient',
'bool',
@ -265,9 +253,6 @@ EODOC
))
->setSummary(pht('Trust "Reply-To" headers for authentication.'))
->setDescription($reply_to_description),
$this->newOption('metamta.placeholder-to-recipient', 'string', null)
->setSummary(pht('Placeholder for mail with only CCs.'))
->setDescription($placeholder_description),
$this->newOption('metamta.public-replies', 'bool', false)
->setBoolOptions(
array(

View file

@ -857,7 +857,7 @@ final class PhabricatorMetaMTAMail
// aren't in the form "<string@domain.tld>"; this is also required
// by RFC 2822, although some clients are more liberal in what they
// accept.
$domain = PhabricatorEnv::getEnvConfig('metamta.domain');
$domain = $this->newMailDomain();
$value = '<'.$value.'@'.$domain.'>';
if ($is_first && $mailer->supportsMessageIDHeader()) {
@ -1017,18 +1017,13 @@ final class PhabricatorMetaMTAMail
return null;
}
// Some mailers require a valid "To:" in order to deliver mail. If we
// don't have any "To:", try to fill it in with a placeholder "To:".
// If that also fails, move the "Cc:" line to "To:".
// Some mailers require a valid "To:" in order to deliver mail. If we don't
// have any "To:", fill it in with a placeholder "To:". This allows client
// rules based on whether the recipient is in "To:" or "CC:" to continue
// behaving in the same way.
if (!$add_to) {
$placeholder_key = 'metamta.placeholder-to-recipient';
$placeholder = PhabricatorEnv::getEnvConfig($placeholder_key);
if ($placeholder !== null) {
$add_to = array($placeholder);
} else {
$add_to = $add_cc;
$add_cc = array();
}
$void_recipient = $this->newVoidEmailAddress();
$add_to = array($void_recipient->getAddress());
}
$add_to = array_unique($add_to);
@ -1467,6 +1462,19 @@ final class PhabricatorMetaMTAMail
return '/mail/detail/'.$this->getID().'/';
}
private function newMailDomain() {
$install_uri = PhabricatorEnv::getURI('/');
$install_uri = new PhutilURI($install_uri);
return $install_uri->getDomain();
}
public function newVoidEmailAddress() {
$domain = $this->newMailDomain();
$address = "void-recipient@{$domain}";
return new PhutilEmailAddress($address);
}
/* -( Routing )------------------------------------------------------------ */

View file

@ -45,7 +45,6 @@ in your configuration:
- **metamta.default-address** determines where mail is sent "From" by
default. If your domain is `example.org`, set this to something like
`noreply@example.org`.
- **metamta.domain** should be set to your domain, e.g. `example.org`.
- **metamta.can-send-as-user** should be left as `false` in most cases,
but see the documentation for details.