Local MTA: Configuring Postfix for Inbound Email – Phabricator
Whenever something is update on a software development platform, usually an email is sent to all subscribed users. Phabricator let you reply to those emails and perform a specific action like assign, claim, close, change priority and status, unsubscribe, etc. In order for this to function with a local MTA like Postfix, a manual setup must be done.
Before everything, read the official page on configuring inbound email to see how things work and what configuration must be made. I’ll go again through some setup already mentioned in the guide, just to mention the most important steps and some additional ones.
Navigate to Mail Configuration page and check if the following options are set:
metamta.domain: domain.com metamta.default-address: firstname.lastname@example.org metamta.reply-handler-domain: phab.domain.com metamta.single-reply-handler-prefix: post
metamta.single-reply-handler-prefix option is not mandatory, but this is what I have chosen for my setup because I have other email accounts on
phab.domain.com. For more about this, check the link above.
Local MTA: Installing Mailparse
mailparse package as described in the guide (I managed to do it via
If you have individual files in
/etc/php.d/, then search for a
mbstring file (I had a
20-mbstring.ini file). All the configs in this directory are loaded alphabetically, so in order to have this package loaded after the
mbstring, create a file with a name that will sort higher. For my setup, I’ve created a
21-mailparse.ini file and added the following content to it:
; Enable mailparse extension module extension=mailparse.so
Local MTA: Configuring Postfix
mail_handler.php script must be run by Postfix with a user that has permissions over it.
By default, Postfix runs everything with its own user, therefore if we add the user & script in the
/etc/aliases (as described in the guide – Configuring Sendmail section) an error with occur when Postfix will try to run the
mail_handler.php script, so we’re going to make some local aliases and then load them in the main configuration of Postfix.
phab.domain.com we’ll assume that the owner of the
Now, change directory to
/home/dummy/phab.domain.com/ and run the following:
[dummy@host ~]$ sudo ln -s /home/dummy/phab.domain.com/public_html/phabricator/scripts/mail/mail_handler.php /etc/smrsh/ [dummy@host ~]$ echo "dummy: |/home/dummy/phab.domain.com/public_html/phabricator/scripts/mail/mail_handler.php" >> .phabricator_inbound_aliases [dummy@host ~]$ postalias .phabricator_inbound_aliases
The last two commands will create two files:
.phabricator_inbound_aliases.db. Both files must be owned by
/etc/postfix/main.cf in edit mode, search for
alias_database and add the domain specific alias after the existing value, separating it via comma. In the end it should look like this:
alias_maps = hash:/etc/aliases, hash:/home/dummy/phab.domain.com/.phabricator_inbound_aliases alias_database = hash:/etc/aliases, hash:/home/dummy/phab.domain.com/.phabricator_inbound_aliases
After making this change, run
/etc/postfix/virtual in edit mode and at the end add a new line:
This will redirect all email that goes to the specified domain to the
dummy alias, which will run the
mail_handler.php script that will parse the email and execute given commands.
Restart Apache & Postfix and you’re all set.