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

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.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Pat PribelSenior - Systems EngineerCommented:
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).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Daniel McAllisterPresident, IT4SOHO, LLCCommented:
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!

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

MBNDAuthor Commented:
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!
mbdn,  are there any other questions you needed help with?  if not please close this question.

MBNDAuthor Commented:
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!
Pat PribelSenior - Systems EngineerCommented:
If you decide to go the route of letting exchange do the relaying and you have some more questions just let me know.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Servers

From novice to tech pro — start learning today.