Piping Emails Through Your Invision Community Using Exim

It can get tricky without having cPanel, but you tend to learn a lot without it


With the plethora of great updates released and forthcoming from Invision Power Services, I thought it was about time to hop back into it with a new project. While setting up the Invision Community suite of products, I came across the option to pipe emails into the included support system (you’ll need the Commerce application for the support system).

POP3 and an external service, SendGrid, are the other two options, but I decided against those. Piping is the “cleanest” method of routing the emails into Invision Community, and that’s precisely what I like. Clean.

Without having access to cPanel on the server I’ve set the suite up on, it got fairly tricky. While I do manage my own servers, I’m not particularly well-versed in MTAs — they can get confusing if it’s not your field. But I managed to get it done.

If you’re using Exim4 on a Ubuntu (or anything related to Debian), this quick guide should help you out. I’ll assume you’ve already gotten Exim set up on your server and it’s working properly. If not, follow one of the plethora of guides on the internet.

This will work with either the split configuration or the full, monolithic config (exim4.conf.template). We’ll be going through the split, but it’s easy enough to piece this together if you’re using the full one.

Head into the /etc/exim4/conf.d/router directory and create a file named something like 380_local-config_vdomains.

Go ahead and add your routers. In the example below I’m showing you two different routers I use for two different sites; the latter is the one we’ll be using for piping, whereas the former is there just as an example.

# One of the routers I use for examplesite1.com
examplesite1:
  debug_print = "R: dnslookup for $local_part@$domain"
  driver = dnslookup
  domains = examplesite1.com
  transport = remote_smtp
  # ignore private rfc1918 and APIPA addresses
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 192.168.0.0/16 :\
                        172.16.0.0/12 : 10.0.0.0/8 : 169.254.0.0/16 :\
                        255.255.255.255
  no_more

# The important bit we need.
# Keep in mind routers can be named what you want
# But I find it easier to just use the site name to avoid confusion.
# Or simply use comments like this one.
invisionwebsite:
  driver = accept
  transport = program_transport
  no_more

Save that file and head into /etc/exim4/conf.d/transport. This time we’ll be making a file called 380_local-config_program_transport.

$ cd /etc/exim4/conf.d/transport
$ sudo nano 380_local-config_program_transport

Paste this into the new file and save it.

# See invisionwebsite router
program_transport:
  debug_print = "T: program_transport for $local_part@$domain"
  driver = pipe
  command = /var/www/invisonwebsite.com/public_html/applications/core/interface/incomingemail/piping.php
  user = www-data
  group = www-data

“Use Piping”

Make sure you change the command directory to where your piping.php file is located. When you’re in the Support Settings section of your Invision Community, it’ll tell you what that is in the Incoming Emails tab.

Also change the user and group if you need to. www-data is common on Ubuntu systems for web servers like Apache and Nginx. Another common one is nobody.

Make sure you have your MX record set for that specific Invision website so that it goes through Exim and not something like Google Apps (which is what I use as a backup for my particular Invision Community website).

Create departments with the emails you want to be able to be contacted through, and you’re good to go.

$ sudo update-exim4.conf
$ sudo service exim4 restart