Using Multiple Mail Servers with Interworx

After working through this issue for days, and knowing it could be done - I finally was able to get dual mail servers in a single domain with qmail / Interworx working so I thought I’d share with the group the actual implementation.

This is hardly my brainchild, I give all the credit to this obscure post [URL=“”]

So first an overview of the ‘problem’ I was trying to solve.

We have a “fully featured” Kerio mail server for our main mail server. This server provides exchange-esque features (calendar, contacts, mobile, chat, advanced administration, etc) but like all commercial mail servers, the per user price is, well, greater than zero.

We were trying to fill a need to have other email address’ in our domain, but didn’t want to pay the price for transactional, standard POP3, or seldom used accounts to have all the features associated with the main domain. Or more importantly, have our transactional based emails cause our main emails to get a bad reputation if ALTMAIL got listed for SPAM somewhere (as often happens with transactional based systems.) Out of all the possible mail servers, it just so happens that qmail has a ‘simpler’ way to do this than other servers we’ve tried.

So to jump to the chase here’s how it works:[SIZE=1] (graphic idea borrowed from link above replace with your domain name)
We setup two servers, HQMAIL and ALTMAIL, Kerio and Interworx respectively.

[TD]Nick <>
Nancy <>[/TD]
[TD]Alex <>
Alice <>[/TD]

Nick and Nancy have accounts on our Kerio Server, Alex and Alice have accounts on our Interworx server. Our MX records are pointed at HQMAIL, so when an email for let’s say Alex comes in it checks in at HQMAIL, and doesn’t find the account, Kerio forwards the mail to ALTMAIL. This transfer is facilitated by kerio’s built in forwarding function.

So now Alex’s email is happily delivered to ALTMAIL and the transaction is done.

However things get difficult if Alex wants to email Nick. Altmail knows that it’s serving’s domain and tries to deliver Nick’s email locally - which fails. So the solution is to setup a forwarder ‘pipe’ with qmail. The secret is in the domain directory ~vpopmail/domains/ as this houses the folders for the users. By placing a .qmail-{username} file in that directory we can tell the server to do something different with this user rather than deliver locally.

As the post suggests simply creating a file for Nick on the Interworx server at ~vpopmail/domains/ we tell Interworx to do something else with the email. The contents of .qmail-nick in this instance are { |qmail-remote ‘[]’ “$SENDER” “$EXT@$” } (everything between the {} but not the {} themselves)

(This is where the post reference jammed me up, for some reason the $HOST variable did not pass in my setup, so by replacing $HOST with the actual domain I got it to work in Interworx)

Then simply put a symbolic link to the .qmail-nick file named .qmail-nick-default in the same directory and its all set. B/T/W to setup groups with members across domains you just setup the group in the Interworx (ALTMAIL) server, it then delivers the mail using the forwarding files appropriately - but if the group exists on the main server, eg all members of the group are there - setup a file .qmail-groupname on the Interworx server to re-route it back.

Now I have a “full service” email server and a ‘lite’ email server. But this is not without it’s challenges, for as the company grows someone is going to have to make sure these files exist with the correct pointers to servers. In my case I only have to update Interworx with any Kerio users, which only the “real employees” get one of those - so it should be manageable.