one domain, two different email MTA's (servers)

Posted on 2008-11-10
Last Modified: 2013-12-02
here is the scenario:
tow companies are merging: and
A new domain is being created:
company "abc" has 250 users on Exchange 2003
company "xyz" has 2800 users on qmail server

The company does not want to deal with exchange liscences for 3000 users, so they want one domain with two different email servers.
The new domain "123" will be used for all users in the new company, so they want the following: mail goes to barracuda spam & virus filter
But then we have a problem, two mail servers behind it, sharing the same domain name...  So basically you have mail account "shawn@123" that is on the exchange server, and you have "bill@123" who is on the qmail server.
How do I route or forward which email belongs to whisch server?  one server I am just fine, but two on the same domain I haven't attempted before.

Question by:MBND
    LVL 9

    Expert Comment

    it will be a little odd, but i believe i did this once.

    exchange :, make a custom recipient for the other users so that they have two email addresses, one, and one with, use this to foreword to the qmail system.

    i do not know qmail well enough to say how to control the reply address but this should work.

    LVL 5

    Accepted Solution

    There are a couple ways to do this in Exchange. I also am not familiar enough with qmail to know it if would do the same or do it better.
    Take a look at this article, it goes into a couple different ways of accomplishing this. We had to do something similar and created the new Recipient policies that allowed us to the define the shared email namespace as non-authoritative. Once defined as non authoritative exchange will route the email externally if the address doesn't exist in it's active directory. Read this article though because it has a simpler scenario of just pointing any non-resolved addresses to a specific host (in your case you can point it to the qmail server).
    LVL 20

    Assisted Solution

    by:Daniel McAllister
    This is MUCH easier in QMail -- not because of QMail's superiority (which is there, it's just not the reason why it is so much easler), but because there are only 250 users on the Exchange server -- so there are many MANY fewer "edits" that have to be made.

    Here's what you want to do (re-worded from your original post)...
     - you have 250 users at that currently use Exchange 2003. Their e-mail addresses will be converted to
     - you have 2800 users at that currently use QMail. Their e-mail addresses will also be converted to
     - Both QMail and Exchange sit behind the same firewall on the same public IP address.

    First of all, for the benefit of everyone on the outside that doesn't get the message that & are becoming, LEAVE the existing email accounts alone, but change the MX records on the DNS servers to point to the PUBLIC IP address of the QMail server. Also, add to the Qmail rcpthosts file, and make the entry below in the smtproutes file, where is the LAN address of the Excahnge server:
    Lastly, make sure that the Exchange server "whitelists" mail from the LAN address of the QMail server. (NOTE: You CAN use public IP addresses, but if they're co-located, LAN traffic will be MUCH faster & safer.)

    OK... so now & both go to the Qmail server, and gets forwarded to Exchange 2003 (but xyz does not).

    So next, we create the entries.
     1) First, add the extra SMTP entry for each of your 250 users on the Exchange 2003 server (have fun!)
     2) Next, you'll want the QMail server (& Exchange, probably) to default (advertise) as, so make the appropriate changes in /var/qmail/control and on Exchange
     3) Then, setup the xyz users to be able to send & receive as both xyz and 123. You haven't said how the QMail is setup, so I'll show you in the 2 most common ways:
       A) If you're using system users:
          - Just add back to your locals file (you SHOULD have changed it in step 2 above!)... THAT'S IT! Since the usernames (the part of the email address BEFORE the @) didn't change, both domains (xyz & 123) will map users to the same place
       B) Iif you're using a user manager (like vpopmail or vmailmgr):
          - In this case your users won't so easily be switched to the domain. The user manager has stored all of the user accounts separately... but you CAN create an ALIAS domain that will just remap one domain over the other:
          - In the case of vpopmail, go to the folder /home/vpopmail/bin and run the command:
          - follow your normal route for adding users, but for each user create a forward to the exchange server. (Do this in the .qmail file for each user).
     4) Finally, setup the abc users on the Qmail system. Follow your normal route for adding users, but for each user create a forward to the exchange server. (Do this in the .qmail file for each user, or in the usermanager configuration).

    That's it! Now all incoming mail for,, & arrives at the QMail server. Messages for former users can be addressed as either OR, and they go to the same place. Messages for the former users are processed a little differently:
     - is sent directly to the Exchange server
     - is processed by QMail, and based on the USER settings, is forwarded to Exchange

    As a last comment -- at first glance, we wouldn't need to worry about outbound delivery. Both the QMail & Exchange server could open port 25 sessions with other MTA's simultaneously and be validated with the same SPF or other criteria (perhaps, excepting DomainKeys). HOWEVER, that poses a problem for when users want to send messages to each other... the issue isn't so much for the QMail server (which now has the extra 250 accounts, and knows how to deal with them), but with the Exchange server (which DOESN'T know about the extra 2800 former xyz accounts. As a result, I recommend having ALL outbound mail process through the QMail server (unless you WANT to configure Exchange to have 2800 more users!)

    I hope this helps.... GOOD LUCK!


    Author Comment

    it4soho, thank you for the very detailed info.  I will take that with me to the guys I have helping us on the mail servers, we found a company that specializes in qmail, and your description, sounds familiar.

    I appreciate everyones responses so far.
    Thank you, and I will let you guys know which way we go.
    Thanks again!
    LVL 9

    Expert Comment

    mbdn,  are there any other questions you needed help with?  if not please close this question.


    Author Closing Comment

    Thank you for the info, the rest of my server infrastructure wont be here for a couple weeks, so then I can set up a couple test boxes to figure out what is going to work best.
    Thanks again for the excellent ideas!
    LVL 5

    Expert Comment

    If you decide to go the route of letting exchange do the relaying and you have some more questions just let me know.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
    Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
    To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now