diff --git a/src/applications/metamta/adapter/PhabricatorMailPostmarkAdapter.php b/src/applications/metamta/adapter/PhabricatorMailPostmarkAdapter.php index 2381ff04bf..cdc5a830c4 100644 --- a/src/applications/metamta/adapter/PhabricatorMailPostmarkAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailPostmarkAdapter.php @@ -1,124 +1,125 @@ 'string', 'inbound-addresses' => 'list', )); // Make sure this is properly formatted. PhutilCIDRList::newList($options['inbound-addresses']); } public function newDefaultOptions() { return array( 'access-token' => null, 'inbound-addresses' => array( // Via Postmark support circa February 2018, see: // // https://postmarkapp.com/support/article/800-ips-for-firewalls // // "Configuring Outbound Email" should be updated if this changes. // - // These addresses were last updated in January 2019. + // These addresses were last updated in December 2021. '50.31.156.6/32', '50.31.156.77/32', '18.217.206.57/32', + '3.134.147.250/32', ), ); } public function sendMessage(PhabricatorMailExternalMessage $message) { $access_token = $this->getOption('access-token'); $parameters = array(); $subject = $message->getSubject(); if ($subject !== null) { $parameters['Subject'] = $subject; } $from_address = $message->getFromAddress(); if ($from_address) { $parameters['From'] = (string)$from_address; } $to_addresses = $message->getToAddresses(); if ($to_addresses) { $to = array(); foreach ($to_addresses as $address) { $to[] = (string)$address; } $parameters['To'] = implode(', ', $to); } $cc_addresses = $message->getCCAddresses(); if ($cc_addresses) { $cc = array(); foreach ($cc_addresses as $address) { $cc[] = (string)$address; } $parameters['Cc'] = implode(', ', $cc); } $reply_address = $message->getReplyToAddress(); if ($reply_address) { $parameters['ReplyTo'] = (string)$reply_address; } $headers = $message->getHeaders(); if ($headers) { $list = array(); foreach ($headers as $header) { $list[] = array( 'Name' => $header->getName(), 'Value' => $header->getValue(), ); } $parameters['Headers'] = $list; } $text_body = $message->getTextBody(); if ($text_body !== null) { $parameters['TextBody'] = $text_body; } $html_body = $message->getHTMLBody(); if ($html_body !== null) { $parameters['HtmlBody'] = $html_body; } $attachments = $message->getAttachments(); if ($attachments) { $files = array(); foreach ($attachments as $attachment) { $files[] = array( 'Name' => $attachment->getFilename(), 'ContentType' => $attachment->getMimeType(), 'Content' => base64_encode($attachment->getData()), ); } $parameters['Attachments'] = $files; } id(new PhutilPostmarkFuture()) ->setAccessToken($access_token) ->setMethod('email', $parameters) ->setTimeout(60) ->resolve(); } } diff --git a/src/docs/user/configuration/configuring_inbound_email.diviner b/src/docs/user/configuration/configuring_inbound_email.diviner index b1ad08b7dd..39982b10cd 100644 --- a/src/docs/user/configuration/configuring_inbound_email.diviner +++ b/src/docs/user/configuration/configuring_inbound_email.diviner @@ -1,291 +1,294 @@ @title Configuring Inbound Email @group config This document contains instructions for configuring inbound email, so users may interact with some Phabricator applications via email. Preamble ======== Phabricator can process inbound mail in two general ways: **Handling Replies**: When users reply to email notifications about changes, Phabricator can turn email into comments on the relevant discussion thread. **Creating Objects**: You can configure an address like `bugs@yourcompany.com` to create new objects (like tasks) when users send email. In either case, users can interact with objects via mail commands to apply a broader set of changes to objects beyond commenting. (For example, you can use `!close` to close a task or `!priority` to change task priority.) To configure inbound mail, you will generally: - Configure some mail domain to submit mail to Phabricator for processing. - For handling replies, set `metamta.reply-handler-domain` in your configuration. - For handling email that creates objects, configure inbound addresses in the relevant application. See below for details on each of these steps. Configuration Overview ====================== Usually, the most challenging part of configuring inbound mail is getting mail delivered to Phabricator for processing. This step can be made much easier if you use a third-party mail service which can submit mail to Phabricator via webhooks. Some available approaches for delivering mail to Phabricator are: | Receive Mail With | Setup | Cost | Notes | |--------|-------|------|-------| -| Mailgun | Easy | Cheap | Recommended | | Postmark | Easy | Cheap | Recommended | | SendGrid | Easy | Cheap | | +| Mailgun | Easy | Cheap | Discouraged | | Local MTA | Difficult | Free | Discouraged | The remainder of this document walks through configuring Phabricator to receive mail, and then configuring your chosen transport to deliver mail to Phabricator. Configuring "Reply" Email ========================= By default, Phabricator uses a `noreply@phabricator.example.com` email address as the "From" address when it sends mail. The exact address it uses can be configured with `metamta.default-address`. When a user takes an action that generates mail, Phabricator sets the "Reply-To" addresss for the mail to that user's name and address. This means that users can reply to email to discuss changes, but: the conversation won't be recorded in Phabricator; and users will not be able to use email commands to take actions or make edits. To change this behavior so that users can interact with objects in Phabricator over email, change the configuration key `metamta.reply-handler-domain` to some domain you configure according to the instructions below, e.g. `phabricator.example.com`. Once you set this key, email will use a "Reply-To" like `T123+273+af310f9220ad@phabricator.example.com`, which -- when configured correctly, according to the instructions below -- will parse incoming email and allow users to interact with Differential revisions, Maniphest tasks, etc. over email. If you don't want Phabricator to take up an entire domain (or subdomain) you can configure a general prefix so you can use a single mailbox to receive mail on. To make use of this set `metamta.single-reply-handler-prefix` to the prefix of your choice, and Phabricator will prepend this to the "Reply-To" mail address. This works because everything up to the first (optional) '+' character in an email address is considered the receiver, and everything after is essentially ignored. Configuring "Create" Email ========================== You can set up application email addresses to allow users to create objects via email. For example, you could configure `bugs@phabricator.example.com` to create a Maniphest task out of any email which is sent to it. You can find application email settings for each application at: {nav icon=home, name=Home > Applications > type=instructions, name="Select an Application" > icon=cog, name=Configure} Not all applications support creating objects via email. In some applications, including Maniphest, you can also configure Herald rules with the `[ Content source ]` and/or `[ Receiving email address ]` fields to route or handle objects based on which address mail was sent to. You'll also need to configure the actual mail domain to submit mail to Phabricator by following the instructions below. Phabricator will let you add any address as an application address, but can only process mail which is actually delivered to it. Security ======== The email reply channel is "somewhat" authenticated. Each reply-to address is unique to the recipient and includes a hash of user information and a unique object ID, so it can only be used to update that object and only be used to act on behalf of the recipient. However, if an address is leaked (which is fairly easy -- for instance, forwarding an email will leak a live reply address, or a user might take a screenshot), //anyone// who can send mail to your reply-to domain may interact with the object the email relates to as the user who leaked the mail. Because the authentication around email has this weakness, some actions (like accepting revisions) are not permitted over email. This implementation is an attempt to balance utility and security, but makes some sacrifices on both sides to achieve it because of the difficulty of authenticating senders in the general case (e.g., where you are an open source project and need to interact with users whose email accounts you have no control over). You can also set `metamta.public-replies`, which will change how Phabricator delivers email. Instead of sending each recipient a unique mail with a personal reply-to address, it will send a single email to everyone with a public reply-to address. This decreases security because anyone who can spoof a "From" address can act as another user, but increases convenience if you use mailing lists and, practically, is a reasonable setting for many installs. The reply-to address will still contain a hash unique to the object it represents, so users who have not received an email about an object can not blindly interact with it. If you enable application email addresses, those addresses also use the weaker "From" authentication mechanism. NOTE: Phabricator does not currently attempt to verify "From" addresses because this is technically complex, seems unreasonably difficult in the general case, and no installs have had a need for it yet. If you have a specific case where a reasonable mechanism exists to provide sender verification (e.g., DKIM signatures are sufficient to authenticate the sender under your configuration, or you are willing to require all users to sign their email), file a feature request. Testing and Debugging Inbound Email =================================== You can use the `bin/mail` utility to test and review inbound mail. This can help you determine if mail is being delivered to Phabricator or not: phabricator/ $ ./bin/mail list-inbound # List inbound messages. phabricator/ $ ./bin/mail show-inbound # Show details about a message. You can also test receiving mail, but note that this just simulates receiving the mail and doesn't send any information over the network. It is primarily aimed at developing email handlers: it will still work properly if your inbound email configuration is incorrect or even disabled. phabricator/ $ ./bin/mail receive-test # Receive test message. Run `bin/mail help ` for detailed help on using these commands. Mailgun Setup ============= To use Mailgun, you need a Mailgun account. You can sign up at . Provided you have such an account, configure it like this: - Configure a mail domain according to Mailgun's instructions. - Add a Mailgun route with a `catch_all()` rule which takes the action `forward("https://phabricator.example.com/mail/mailgun/")`. Replace the example domain with your actual domain. - Configure a mailer in `cluster.mailers` with your Mailgun API key. +Use of Mailgun is discouraged because of concerns that they may not be a +trustworthy custodian of sensitive data. See for +discussion and context. Postmark Setup ============== To process inbound mail from Postmark, configure this URI as your inbound webhook URI in the Postmark control panel: ``` https:///mail/postmark/ ``` See also the Postmark section in @{article:Configuring Outbound Email} for discussion of the remote address whitelist used to verify that requests this endpoint receives are authentic requests originating from Postmark. SendGrid Setup ============== To use SendGrid, you need a SendGrid account with access to the "Parse API" for inbound email. Provided you have such an account, configure it like this: - Configure an MX record according to SendGrid's instructions, i.e. add `phabricator.example.com MX 10 mx.sendgrid.net.` or similar. - Go to the "Parse Incoming Emails" page on SendGrid () and add the domain as the "Hostname". - Add the URL `https://phabricator.example.com/mail/sendgrid/` as the "Url", using your domain (and HTTP instead of HTTPS if you are not configured with SSL). - If you get an error that the hostname "can't be located or verified", it means your MX record is either incorrectly configured or hasn't propagated yet. - Set `metamta.reply-handler-domain` to `phabricator.example.com` (whatever you configured the MX record for). That's it! If everything is working properly you should be able to send email to `anything@phabricator.example.com` and it should appear in `bin/mail list-inbound` within a few seconds. Local MTA: Installing Mailparse =============================== If you're going to run your own MTA, you need to install the PECL mailparse extension. In theory, you can do that with: $ sudo pecl install mailparse You may run into an error like "needs mbstring". If so, try: $ sudo yum install php-mbstring # or equivalent $ sudo pecl install -n mailparse If you get a linker error like this: COUNTEREXAMPLE PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mailparse.so' - /usr/lib64/php/modules/mailparse.so: undefined symbol: mbfl_name2no_encoding in Unknown on line 0 ...you need to edit your php.ini file so that mbstring.so is loaded **before** mailparse.so. This is not the default if you have individual files in `php.d/`. Local MTA: Configuring Sendmail =============================== Before you can configure Sendmail, you need to install Mailparse. See the section "Installing Mailparse" above. Sendmail is very difficult to configure. First, you need to configure it for your domain so that mail can be delivered correctly. In broad strokes, this probably means something like this: - add an MX record; - make sendmail listen on external interfaces; - open up port 25 if necessary (e.g., in your EC2 security policy); - add your host to /etc/mail/local-host-names; and - restart sendmail. Now, you can actually configure sendmail to deliver to Phabricator. In `/etc/aliases`, add an entry like this: phabricator: "| /path/to/phabricator/scripts/mail/mail_handler.php" If you use the `PHABRICATOR_ENV` environmental variable to select a configuration, you can pass the value to the script as an argument: .../path/to/mail_handler.php This is an advanced feature which is rarely used. Most installs should run without an argument. After making this change, run `sudo newaliases`. Now you likely need to symlink this script into `/etc/smrsh/`: sudo ln -s /path/to/phabricator/scripts/mail/mail_handler.php /etc/smrsh/ Finally, edit `/etc/mail/virtusertable` and add an entry like this: @yourdomain.com phabricator@localhost That will forward all mail to @yourdomain.com to the Phabricator processing script. Run `sudo /etc/mail/make` or similar and then restart sendmail with `sudo /etc/init.d/sendmail restart`. diff --git a/src/docs/user/configuration/configuring_outbound_email.diviner b/src/docs/user/configuration/configuring_outbound_email.diviner index 736d4f625c..9acf3abe10 100644 --- a/src/docs/user/configuration/configuring_outbound_email.diviner +++ b/src/docs/user/configuration/configuring_outbound_email.diviner @@ -1,512 +1,517 @@ @title Configuring Outbound Email @group config Instructions for configuring Phabricator to send email and other types of messages, like text messages. Overview ======== Phabricator sends outbound messages through "mailers". Most mailers send email and most messages are email messages, but mailers may also send other types of messages (like text messages). Phabricator can send outbound messages through multiple different mailers, including a local mailer or various third-party services. Options include: | Send Mail With | Setup | Cost | Inbound | Media | Notes | |----------------|-------|------|---------|-------|-------| | Postmark | Easy | Cheap | Yes | Email | Recommended | -| Mailgun | Easy | Cheap | Yes | Email | Recommended | | Amazon SES | Easy | Cheap | No | Email | | | SendGrid | Medium | Cheap | Yes | Email | | | Twilio | Easy | Cheap | No | SMS | Recommended | | Amazon SNS | Easy | Cheap | No | SMS | Recommended | | External SMTP | Medium | Varies | No | Email | Gmail, etc. | | Local SMTP | Hard | Free | No | Email | sendmail, postfix, etc | | Custom | Hard | Free | No | All | Write a custom mailer. | | Drop in a Hole | Easy | Free | No | All | Drops mail in a deep, dark hole. | +| Mailgun | Easy | Cheap | Yes | Email | Discouraged | See below for details on how to select and configure mail delivery for each mailer. -For email, Postmark or Mailgun are recommended because they make it easy to -set up inbound and outbound mail and have good track records in our production -services. Other services will also generally work well, but they may be more -difficult to set up. +For email, Postmark is recommended because it makes it easy to set up inbound +and outbound mail and has a good track record in our production services. Other +services will also generally work well, but they may be more difficult to set +up. For SMS, Twilio or SNS are recommended. They're also your only upstream options. If you have some internal mail or messaging service you'd like to use you can also write a custom mailer, but this requires digging into the code. Phabricator sends mail in the background, so the daemons need to be running for it to be able to deliver mail. You should receive setup warnings if they are not. For more information on using daemons, see @{article:Managing Daemons with phd}. Outbound "From" and "To" Addresses ================================== When Phabricator sends outbound mail, it must select some "From" address to send mail from, since mailers require this. When mail only has "CC" recipients, Phabricator generates a dummy "To" address, since some mailers require this and some users write mail rules that depend on whether they appear in the "To" or "CC" line. In both cases, the address should ideally correspond to a valid, deliverable mailbox that accepts the mail and then simply discards it. If the address is not valid, some outbound mail will bounce, and users will receive bounces when they "Reply All" even if the other recipients for the message are valid. In contrast, if the address is a real user address, that user will receive a lot of mail they probably don't want. If you plan to configure //inbound// mail later, you usually don't need to do anything. Phabricator will automatically create a `noreply@` mailbox which works the right way (accepts and discards all mail it receives) and automatically use it when generating addresses. If you don't plan to configure inbound mail, you may need to configure an address for Phabricator to use. You can do this by setting `metamta.default-address`. Configuring Mailers =================== Configure one or more mailers by listing them in the the `cluster.mailers` configuration option. Most installs only need to configure one mailer, but you can configure multiple mailers to provide greater availability in the event of a service disruption. A valid `cluster.mailers` configuration looks something like this: ```lang=json [ { - "key": "mycompany-mailgun", - "type": "mailgun", + "key": "mycompany-postmark", + "type": "postmark", "options": { "domain": "mycompany.com", "api-key": "..." } }, ... ] ``` The supported keys for each mailer are: - `key`: Required string. A unique name for this mailer. - `type`: Required string. Identifies the type of mailer. See below for options. - `priority`: Optional string. Advanced option which controls load balancing and failover behavior. See below for details. - `options`: Optional map. Additional options for the mailer type. - `inbound`: Optional bool. Use `false` to prevent this mailer from being used to receive inbound mail. - `outbound`: Optional bool. Use `false` to prevent this mailer from being used to send outbound mail. - `media`: Optional list. Some mailers support delivering multiple types of messages (like Email and SMS). If you want to configure a mailer to support only a subset of possible message types, list only those message types. Normally, you do not need to configure this. See below for a list of media types. The `type` field can be used to select these mailer services: - - `mailgun`: Use Mailgun. - `ses`: Use Amazon SES. - `sendgrid`: Use SendGrid. - `postmark`: Use Postmark. - `twilio`: Use Twilio. - `sns`: Use Amazon SNS. + - `mailgun`: Use Mailgun. It also supports these local mailers: - `sendmail`: Use the local `sendmail` binary. - `smtp`: Connect directly to an SMTP server. - `test`: Internal mailer for testing. Does not send mail. You can also write your own mailer by extending `PhabricatorMailAdapter`. The `media` field supports these values: - `email`: Configure this mailer for email. - `sms`: Configure this mailer for SMS. Once you've selected a mailer, find the corresponding section below for instructions on configuring it. Setting Complex Configuration ============================= Mailers can not be edited from the web UI. If mailers could be edited from the web UI, it would give an attacker who compromised an administrator account a lot of power: they could redirect mail to a server they control and then intercept mail for any other account, including password reset mail. For more information about locked configuration options, see @{article:Configuration Guide: Locked and Hidden Configuration}. Setting `cluster.mailers` from the command line using `bin/config set` can be tricky because of shell escaping. The easiest way to do it is to use the `--stdin` flag. First, put your desired configuration in a file like this: ```lang=json, name=mailers.json [ { "key": "test-mailer", "type": "test" } ] ``` Then set the value like this: ``` phabricator/ $ ./bin/config set --stdin cluster.mailers < mailers.json ``` For alternatives and more information on configuration, see @{article:Configuration User Guide: Advanced Configuration} Mailer: Postmark ================ | Media | Email |---------| | Inbound | Yes |---------| Postmark is a third-party email delivery service. You can learn more at . To use this mailer, set `type` to `postmark`, then configure these `options`: - `access-token`: Required string. Your Postmark access token. - `inbound-addresses`: Optional list. Address ranges which you will accept inbound Postmark HTTP webook requests from. The default address list is preconfigured with Postmark's address range, so you generally will not need to set or adjust it. The option accepts a list of CIDR ranges, like `1.2.3.4/16` (IPv4) or `::ffff:0:0/96` (IPv6). The default ranges are: ```lang=json [ "50.31.156.6/32", "50.31.156.77/32", - "18.217.206.57/32" + "18.217.206.57/32", + "3.134.147.250/32" ] ``` -The default address ranges were last updated in January 2019, and were +The default address ranges were last updated in December 2021, and were documented at: Mailer: Mailgun =============== | Media | Email |---------| | Inbound | Yes |---------| +Use of Mailgun is discouraged because of concerns that they may not be a +trustworthy custodian of sensitive data. See for +discussion and context. + Mailgun is a third-party email delivery service. You can learn more at . Mailgun is easy to configure and works well. To use this mailer, set `type` to `mailgun`, then configure these `options`: - `api-key`: Required string. Your Mailgun API key. - `domain`: Required string. Your Mailgun domain. - `api-hostname`: Optional string. Defaults to "api.mailgun.net". If your account is in another region (like the EU), you may need to specify a different hostname. Consult the Mailgun documentation. Mailer: Amazon SES ================== | Media | Email |---------| | Inbound | No |---------| Amazon SES is Amazon's cloud email service. You can learn more at . To use this mailer, set `type` to `ses`, then configure these `options`: - `access-key`: Required string. Your Amazon SES access key. - `secret-key`: Required string. Your Amazon SES secret key. - `region`: Required string. Your Amazon SES region, like `us-west-2`. - `endpoint`: Required string. Your Amazon SES endpoint, like `email.us-west-2.amazonaws.com`. NOTE: Amazon SES **requires you to verify your "From" address**. Configure which "From" address to use by setting `metamta.default-address` in your config, then follow the Amazon SES verification process to verify it. You won't be able to send email until you do this! Mailer: Twilio ================== | Media | SMS |---------| | Inbound | No |---------| Twilio is a third-party notification service. You can learn more at . To use this mailer, set `type` to `twilio`, then configure these options: - `account-sid`: Your Twilio Account SID. - `auth-token`: Your Twilio Auth Token. - `from-number`: Number to send text messages from, in E.164 format (like `+15551237890`). Mailer: Amazon SNS ================== | Media | SMS |---------| | Inbound | No |---------| Amazon SNS is Amazon's cloud notification service. You can learn more at . Note that this mailer is only able to send SMS messages, not emails. To use this mailer, set `type` to `sns`, then configure these options: - `access-key`: Required string. Your Amazon SNS access key. - `secret-key`: Required string. Your Amazon SNS secret key. - `endpoint`: Required string. Your Amazon SNS endpoint. - `region`: Required string. Your Amazon SNS region. You can find the correct `region` value for your endpoint in the SNS documentation. Mailer: SendGrid ================ | Media | Email |---------| | Inbound | Yes |---------| SendGrid is a third-party email delivery service. You can learn more at . You can configure SendGrid in two ways: you can send via SMTP or via the REST API. To use SMTP, configure Phabricator to use an `smtp` mailer. To use the REST API mailer, set `type` to `sendgrid`, then configure these `options`: - `api-key`: Required string. Your SendGrid API key. Older versions of the SendGrid API used different sets of credentials, including an "API User". Make sure you're configuring your "API Key". Mailer: Sendmail ================ | Media | Email |---------| | Inbound | Requires Configuration |---------| This requires a `sendmail` binary to be installed on the system. Most MTAs (e.g., sendmail, qmail, postfix) should install one for you, but your machine may not have one installed by default. For install instructions, consult the documentation for your favorite MTA. Since you'll be sending the mail yourself, you are subject to things like SPF rules, blackholes, and MTA configuration which are beyond the scope of this document. If you can already send outbound email from the command line or know how to configure it, this option is straightforward. If you have no idea how to -do any of this, strongly consider using Postmark or Mailgun instead. +do any of this, strongly consider using Postmark instead. To use this mailer, set `type` to `sendmail`, then configure these `options`: - `message-id`: Optional bool. Set to `false` if Phabricator will not be able to select a custom "Message-ID" header when sending mail via this mailer. See "Message-ID Headers" below. Mailer: SMTP ============ | Media | Email |---------| | Inbound | Requires Configuration |---------| You can use this adapter to send mail via an external SMTP server, like Gmail. To use this mailer, set `type` to `smtp`, then configure these `options`: - `host`: Required string. The hostname of your SMTP server. - `port`: Optional int. The port to connect to on your SMTP server. - `user`: Optional string. Username used for authentication. - `password`: Optional string. Password for authentication. - `protocol`: Optional string. Set to `tls` or `ssl` if necessary. Use `ssl` for Gmail. - `message-id`: Optional bool. Set to `false` if Phabricator will not be able to select a custom "Message-ID" header when sending mail via this mailer. See "Message-ID Headers" below. Disable Mail ============ | Media | All |---------| | Inbound | No |---------| To disable mail, just don't configure any mailers. (You can safely ignore the setup warning reminding you to set up mailers if you don't plan to configure any.) Testing and Debugging Outbound Email ==================================== You can use the `bin/mail` utility to test, debug, and examine outbound mail. In particular: phabricator/ $ ./bin/mail list-outbound # List outbound mail. phabricator/ $ ./bin/mail show-outbound # Show details about messages. phabricator/ $ ./bin/mail send-test # Send test messages. Run `bin/mail help ` for more help on using these commands. By default, `bin/mail send-test` sends email messages, but you can use the `--type` flag to send different types of messages. You can monitor daemons using the Daemon Console (`/daemon/`, or click **Daemon Console** from the homepage). Priorities ========== By default, Phabricator will try each mailer in order: it will try the first mailer first. If that fails (for example, because the service is not available at the moment) it will try the second mailer, and so on. If you want to load balance between multiple mailers instead of using one as a primary, you can set `priority`. Phabricator will start with mailers in the highest priority group and go through them randomly, then fall back to the next group. For example, if you have two SMTP servers and you want to balance requests -between them and then fall back to Mailgun if both fail, configure priorities +between them and then fall back to Postmark if both fail, configure priorities like this: ```lang=json [ { "key": "smtp-uswest", "type": "smtp", "priority": 300, "options": "..." }, { "key": "smtp-useast", "type": "smtp", "priority": 300, "options": "..." }, { - "key": "mailgun-fallback", - "type": "mailgun", + "key": "postmark-fallback", + "type": "postmark", "options": "..." } } ``` Phabricator will start with servers in the highest priority group (the group with the **largest** `priority` number). In this example, the highest group is `300`, which has the two SMTP servers. They'll be tried in random order first. If both fail, Phabricator will move on to the next priority group. In this example, there are no other priority groups. If it still hasn't sent the mail, Phabricator will try servers which are not in any priority group, in the configured order. In this example there is -only one such server, so it will try to send via Mailgun. +only one such server, so it will try to send via Postmark. Message-ID Headers ================== Email has a "Message-ID" header which is important for threading messages correctly in mail clients. Normally, Phabricator is free to select its own "Message-ID" header values for mail it sends. However, some mailers (including Amazon SES) do not allow selection of custom "Message-ID" values and will ignore or replace the "Message-ID" in mail that is submitted through them. When Phabricator adds other mail headers which affect threading, like "In-Reply-To", it needs to know if its "Message-ID" headers will be respected or not to select header values which will produce good threading behavior. If we guess wrong and think we can set a "Message-ID" header when we can't, you may get poor threading behavior in mail clients. For most mailers (like Postmark, Mailgun, and Amazon SES), the correct setting will be selected for you automatically, because the behavior of the mailer is knowable ahead of time. For example, we know Amazon SES will never respect our "Message-ID" headers. However, if you're sending mail indirectly through a mailer like SMTP or Sendmail, the mail might or might not be routing through some mail service which will ignore or replace the "Message-ID" header. For example, your local mailer might submit mail to Mailgun (so "Message-ID" will work), or to Amazon SES (so "Message-ID" will not work), or to some other mail service (which we may not know anything about). We can't make a reliable guess about whether "Message-ID" will be respected or not based only on the local mailer configuration. By default, we check if the mailer has a hostname we recognize as belonging to a service which does not allow us to set a "Message-ID" header. If we don't recognize the hostname (which is very common, since these services are most often configured against the localhost or some other local machine), we assume we can set a "Message-ID" header. If the outbound pathway does not actually allow selection of a "Message-ID" header, you can set the `message-id` option on the mailer to `false` to tell Phabricator that it should not assume it can select a value for this header. For example, if you are sending mail via a local Postfix server which then forwards the mail to Amazon SES (a service which does not allow selection of a "Message-ID" header), your `smtp` configuration in Phabricator should specify `"message-id": false`. Next Steps ========== Continue by: - @{article:Configuring Inbound Email} so users can reply to email they receive about revisions and tasks to interact with them; or - learning about daemons with @{article:Managing Daemons with phd}; or - returning to the @{article:Configuration Guide}.