Phabricator: handling inbound email with Fetchmail

Under: Blog

Posted in email phabricator php
Tagged phabricator
Posted 5 years ago

After reading the Phabricator documentaton for Configuring Inbound Email you may be forgiven for simply running up an account on Mailgun or Sendgrid. On the  flipside, if you don't want your email to be routed through a third party provider, then a local MTA is the only answer. Don't get too scared by the documentation, it's actually fairly easy:


  • Phabricator up and running.

  • A server hosting your Phabricator email, it may be the same server as Phabricator is installed on or it may be somewhere else. For instance '' or similar. It's assumed you've got all the MX records set up for mail delivery.

  • A catch-all IMAP mailbox on that relevant mail server.

  • Mail being delivered to that catch-all mailbox.

  • Root access on your Phabricator server (you've got that, haven't you?) or be nice to your sysadmin. Required so you can install Fetchmail.

  • Ability to get a shell on your server for the same user that Phabricator is installed under.

If you send an email to that catch-all mailbox and it arrives, then you can go ahead, configure Phabricator and install Fetchmail:

  1. Set up your metamta settings per the Phabricator configuring inbound email page. E.g set your metamta.default-address setting to

  2. On your mail server or control panel for the mail server, set up a catch all, something boring like "". This will scoop up all email sent to that domain. Note: There are so many methods and web panels to do the set up of a catch-all for a domain, I'll leave this up to you to work out.

  3. Next you'll, need to install fetchmail:

sudo aptitude install fetchmail

(or yum, apt-get etc etc depending on your distro and personal taste)

Then create a .fetchmailrc file in the home directory of the user that phabricator is installed under. Let's call our user 'phab' for this example.

$ sudo su phab
$ cd
$ pwd
// e.g /home/phab (for instance, your ~ may vary)
$ touch .fetchmailrc
$ chmod 0600 .fetchmailrc
$ vim .fetchmailrc

The contents should look something like this
set daemon 60
set logfile "/home/phab/fetchmail.log"
poll protocol imap port 143:
user "catchall" pass "some.password"
mda "/home/phab/path/to/phabricator/scripts/mail/mail_handler.php"
sslproto tls1
no rewrite
no keep

I'll go through the lines one by one:

  1. set daemon 60 : The fetchmail daemon will poll the configured server every 60 seconds. Change the value as you think necessary.

  2. set logfile "/home/phab/fetchmail.log" : sets up a log file location for fetchmail. Helps with debugging. Optional.

  3. poll protocol imap port 143: : means 'poll' the mail server using IMAP on port 143. Your mail server will not be

  4. user "catchall" pass "some.password" : using this username and password for the catchall mailbox

  5. mda "/home/phab/path/to/phabricator/scripts/mail/mail_handler.php" : redirect the mail found to this script

  6. sslproto tls1 : use TLS1. If you specify an "ssl" command in the fetchmailrc and you have both SSL2 and 3 disabled (See POODLE) then this will fail. Using sslproto on it's own without ssl does the trick and forces TLS usage.

  7. no rewrite : do not allow fetchmail to rewrite any mail headers, this is important.

  8. no keep : delete email off the server after downloading, this is important.

  9. fetchall : get all email, regardless of whether it's been viewed or not. If you log into the mail server and view emails, you still want fetchmail to download them.
    Finally, a semicolon ends the rules for the "poll" settings.

Once this is done, run "fetchmail -v". Fetchmail will background and daemonise per the settings. If you don't wan't verbose mode, omit the "-v".

If all goes well, you should be able to see email replies going into Phabricator within 60 seconds. Phabricator helpfully bounces email with details back to you if something went wrong.

Gotchas and helpers:

  1. There is a bug with using a "Personal (IMAP)" account in the Gmail App for Android in that it doesn't respect the Reply-To header. This means you can't reply to emails using the Android Gmail app  for Personal IMAP accounts and possibly the legacy Email app as well.

  2. Run Fetchmail with fetchmail -v to log requests to your fetchmail log file

  3. Tail your system mail logs, if you can, to check that the email connection is being made. If you experience errors or auth issues they will be logged here.

  4. Run ./phabricator/bin/mail list-inbound to check inbound email status.

Post your comment


No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments