2011-05-12 08:15:02 -07:00
|
|
|
@title Configuring Outbound Email
|
|
|
|
@group config
|
|
|
|
|
|
|
|
Instructions for configuring Phabricator to send mail.
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Overview
|
|
|
|
========
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Phabricator can send outbound email through several different mail services,
|
|
|
|
including a local mailer or various third-party services. Options include:
|
2014-04-21 15:45:29 -07:00
|
|
|
|
|
|
|
| Send Mail With | Setup | Cost | Inbound | Notes |
|
|
|
|
|---------|-------|------|---------|-------|
|
|
|
|
| Mailgun | Easy | Cheap | Yes | Recommended |
|
2018-02-06 09:29:40 -08:00
|
|
|
| Postmark | Easy | Cheap | Yes | Recommended |
|
2014-04-21 15:45:29 -07:00
|
|
|
| Amazon SES | Easy | Cheap | No | Recommended |
|
2018-02-06 05:23:47 -08:00
|
|
|
| SendGrid | Medium | Cheap | Yes | Discouraged |
|
2014-04-21 15:45:29 -07:00
|
|
|
| External SMTP | Medium | Varies | No | Gmail, etc. |
|
2018-02-06 05:23:47 -08:00
|
|
|
| Local SMTP | Hard | Free | No | sendmail, postfix, etc |
|
|
|
|
| Custom | Hard | Free | No | Write a custom mailer for some other service. |
|
2014-04-21 15:45:29 -07:00
|
|
|
| Drop in a Hole | Easy | Free | No | Drops mail in a deep, dark hole. |
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
See below for details on how to select and configure mail delivery for each
|
|
|
|
mailer.
|
2014-04-21 15:45:29 -07:00
|
|
|
|
|
|
|
Overall, Mailgun and SES are much easier to set up, and using one of them is
|
|
|
|
recommended. In particular, Mailgun will also let you set up inbound email
|
|
|
|
easily.
|
|
|
|
|
|
|
|
If you have some internal mail service you'd like to use you can also
|
2018-02-06 05:23:47 -08:00
|
|
|
write a custom mailer, but this requires digging into the code.
|
2014-04-21 15:45:29 -07:00
|
|
|
|
|
|
|
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
|
2012-07-23 12:04:53 -07:00
|
|
|
@{article:Managing Daemons with phd}.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2014-09-02 10:47:34 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Basics
|
|
|
|
======
|
2011-05-12 08:15:02 -07:00
|
|
|
|
|
|
|
Regardless of how outbound email is delivered, you should configure these keys
|
2014-04-21 15:45:29 -07:00
|
|
|
in your configuration:
|
2011-05-12 08:15:02 -07:00
|
|
|
|
|
|
|
- **metamta.default-address** determines where mail is sent "From" by
|
2014-04-21 15:45:29 -07:00
|
|
|
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`.
|
2015-05-31 10:07:45 +10:00
|
|
|
- **metamta.can-send-as-user** should be left as `false` in most cases,
|
2014-04-21 15:45:29 -07:00
|
|
|
but see the documentation for details.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Configuring Mailers
|
|
|
|
===================
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
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.
|
2014-09-02 10:47:34 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
A valid `cluster.mailers` configuration looks something like this:
|
2012-12-09 02:36:40 -08:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
```lang=json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"key": "mycompany-mailgun",
|
|
|
|
"type": "mailgun",
|
|
|
|
"options": {
|
|
|
|
"domain": "mycompany.com",
|
|
|
|
"api-key": "..."
|
|
|
|
}
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
The supported keys for each mailer are:
|
2014-04-21 15:45:29 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
- `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.
|
2014-04-21 15:45:29 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
The `type` field can be used to select these third-party mailers:
|
2014-04-21 15:45:29 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
- `mailgun`: Use Mailgun.
|
|
|
|
- `ses`: Use Amazon SES.
|
|
|
|
- `sendgrid`: Use Sendgrid.
|
2014-04-21 15:45:29 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
It also supports these local mailers:
|
2012-12-09 02:36:40 -08:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
- `sendmail`: Use the local `sendmail` binary.
|
|
|
|
- `smtp`: Connect directly to an SMTP server.
|
|
|
|
- `test`: Internal mailer for testing. Does not send mail.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
You can also write your own mailer by extending
|
|
|
|
`PhabricatorMailImplementationAdapter`.
|
|
|
|
|
|
|
|
Once you've selected a mailer, find the corresponding section below for
|
|
|
|
instructions on configuring it.
|
|
|
|
|
|
|
|
|
2018-02-06 06:20:24 -08:00
|
|
|
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 < mailers.json
|
|
|
|
```
|
|
|
|
|
|
|
|
For alternatives and more information on configuration, see
|
|
|
|
@{article:Configuration User Guide: Advanced Configuration}
|
|
|
|
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Mailer: Mailgun
|
|
|
|
===============
|
|
|
|
|
|
|
|
Mailgun is a third-party email delivery service. You can learn more at
|
|
|
|
<http://www.mailgun.com>. 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.
|
|
|
|
|
|
|
|
|
2018-02-06 09:29:40 -08:00
|
|
|
Mailer: Postmark
|
|
|
|
================
|
|
|
|
|
|
|
|
Postmark is a third-party email delivery serivice. You can learn more at
|
|
|
|
<https://www.postmarkapp.com/>.
|
|
|
|
|
|
|
|
To use this mailer, set `type` to `postmark`, then configure these `options`:
|
|
|
|
|
|
|
|
- `access-token`: Required string. Your Postmark access token.
|
|
|
|
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Mailer: Amazon SES
|
|
|
|
==================
|
|
|
|
|
|
|
|
Amazon SES is Amazon's cloud email service. You can learn more at
|
2011-05-12 08:15:02 -07:00
|
|
|
<http://aws.amazon.com/ses/>.
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
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.
|
|
|
|
- `endpoint`: Required string. Your Amazon SES endpoint.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
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!
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2011-06-12 19:04:34 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Mailer: SendGrid
|
|
|
|
================
|
2011-05-26 10:00:26 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
SendGrid is a third-party email delivery service. You can learn more at
|
|
|
|
<http://sendgrid.com/>.
|
2011-05-26 10:00:26 -07:00
|
|
|
|
|
|
|
You can configure SendGrid in two ways: you can send via SMTP or via the REST
|
2018-02-06 05:23:47 -08:00
|
|
|
API. To use SMTP, configure Phabricator to use an `smtp` mailer.
|
2011-05-26 10:00:26 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
To use the REST API mailer, set `type` to `sendgrid`, then configure
|
|
|
|
these `options`:
|
2011-05-26 10:00:26 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
- `api-user`: Required string. Your SendGrid login name.
|
|
|
|
- `api-key`: Required string. Your SendGrid API key.
|
2011-05-26 10:00:26 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
NOTE: Users have experienced a number of odd issues with SendGrid, compared to
|
|
|
|
fewer issues with other mailers. We discourage SendGrid unless you're already
|
|
|
|
using it.
|
2011-05-26 10:00:26 -07:00
|
|
|
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Mailer: Sendmail
|
|
|
|
================
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
This requires a `sendmail` binary to be installed on
|
|
|
|
the system. Most MTAs (e.g., sendmail, qmail, postfix) should do this, 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 Mailgun or Amazon SES instead.
|
|
|
|
|
|
|
|
To use this mailer, set `type` to `sendmail`. There are no `options` to
|
|
|
|
configure.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
Mailer: STMP
|
|
|
|
============
|
|
|
|
|
|
|
|
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.
|
|
|
|
- `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.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
|
|
|
|
Disable Mail
|
|
|
|
============
|
|
|
|
|
|
|
|
To disable mail, just don't configure any mailers.
|
|
|
|
|
|
|
|
|
|
|
|
Testing and Debugging Outbound Email
|
|
|
|
====================================
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2013-07-10 18:52:42 -07:00
|
|
|
You can use the `bin/mail` utility to test, debug, and examine outbound mail. In
|
|
|
|
particular:
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2013-07-10 18:52:42 -07:00
|
|
|
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.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2013-07-10 18:52:42 -07:00
|
|
|
Run `bin/mail help <command>` for more help on using these commands.
|
2011-05-12 08:15:02 -07:00
|
|
|
|
2015-05-31 10:07:45 +10:00
|
|
|
You can monitor daemons using the Daemon Console (`/daemon/`, or click
|
2011-05-12 08:15:02 -07:00
|
|
|
**Daemon Console** from the homepage).
|
|
|
|
|
2018-02-06 05:23:47 -08:00
|
|
|
|
|
|
|
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
|
|
|
|
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",
|
|
|
|
"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.
|
|
|
|
|
|
|
|
|
|
|
|
Next Steps
|
|
|
|
==========
|
2011-05-12 08:15:02 -07:00
|
|
|
|
|
|
|
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
|
2012-02-27 17:11:25 -08:00
|
|
|
- returning to the @{article:Configuration Guide}.
|