Linux Email

We currently have a Linux box that is functioning as our POP & SMTP email server.  It works fine, but the problem is that we currently host email accounts from several different domains.  Ex./,, etc.  All the email user accounts are set up as popusers.  The poblem arises when I want to create & then for a different customer .  Because they are both in the same group, I have to call the second user joe2 or whatever.  I know this is not the correct way to setup the accounts.  There has to be a way to have each domain in its own "group".  Right now, the DNS for the domain points to the Linux box, which then finds a user by username.  I need to split up the email accounts for different domains.  Please help.    
Who is Participating?
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.

Try using aliases.

You'll need to setup account for joe2 on the linux box, then alias to


what is your mta and pop server?
zzASLANzzAuthor Commented:
I am using sendmail & IPOP3.  Rob, that is not what I need to do.  I have aliases now and that is how it works.  If I have a popuser account called Joe, Linux doesn't care what domain it is, so or both goto the user joe.  I need to be able to have more than one joe and have them differentiated by the domain. So I can provide each customer whose domain I host have a,, etc.  There is no division now.  All the accounts are lumped into one group of popusers.  I just alias the Linux box name with all my other domains I host.  So the Linux box is  I alias, .....At my DNS I point the record for to the Linux box for email.    
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Follow this....

DNS Configuration

First, you need to obtain the new domain name and set up name servers for that new domain:

   1.Choose an available domain name. In our example, we will use

   2.Establish two machines as primary and secondary name servers for your domain. Knowledge of how to do this is assumed;
     otherwise, the book DNS and BIND, 3rd Edition is highly recommended.

   3.Configure MX records for your domain (Note: CNAME records can not be used; see § 5.2.2 of RFC 1123 for details.) MX
     records are explained in the sendmail book, section 15.3, and how to configure them is explained in section 21.3. You have two
     options for MX records:

          If the mail server which will serve your new domain will have a full-time connection to the Internet, it should be the primary
          MX host for your domain. In this configuration, your MX records would look like this:

          IN  MX  10

          Otherwise, you will need to find another machine to queue mail for your domain while you are not connected. Be sure to
          get the machine owners' approval first. You would then point your MX records at that machine. For example:

          IN  MX  10
          IN  MX  20

   4.After the name servers are setup, register your domain with the InterNIC. A good starting point is their Register page.

Sendmail Configuration

Now that DNS is setup, it's time to set up sendmail.

   1.Download sendmail from FTP.Sendmail.ORG/pub/sendmail/. You will automatically be offered a short initial message which will
     indicate the current release.

   2.Build and install sendmail for your machine. In most cases, this consists of unpacking the distribution, reading the READ_ME
     and src/READ_ME files, and typing makesendmail in the src directory. You may have to edit to the Makefile in the
     obj.OSVersion created by makesendmail. After building the sendmail binary, you can install it with makesendmail

   3.Configure sendmail. This is where we go into detail.
        a.First, read the cf/README file thoroughly. It will give you instructions on creating a .mc file in the cf/cf directory.
          Your file will typically look something like:

          #  This file contains definitions for
          VERSIONID(`@(#)     1.0 ( 5/1/97')
          FEATURE(`virtusertable', `dbm /etc/virtusertable')dnl

          Your actual OS will be substituted for solaris2. A typical cf/domain/ file that looks something

          #  This file contains the global definitions for
          VERSIONID(`@(#)   1.0 ( 5/1/97')

          It may have some other FEATURE()'s and define()'s as well. The virtual user table is the key to all of this. Note: if you
          built sendmail with NEWDB instead of NDBM, you will have to use hash instead of dbm in the above line.

        b.Generate your /etc/ file from your file:

          cd sendmail-VERSION/cf/cf
          m4 ../m4/cf.m4 > obj/
          cp obj/ /etc/

   4.Create the virtual user table. This is explained in detail in section 19.6.28 of the sendmail book; an overview is given here. The
     table is a database that maps virtual addresses into real addresses. You create a text file where each line has a key/value pair,
     separated by a TAB. For example:      jschmoe         jschmoe

     In this first example, the address will be mapped to the local user jschmoe,
     will be mapped to the remote user, and anything else coming in to will also go to
     jschmoe.      jschmoe    error:nouser No such user here     yourdomain-list

     In this second example, the address will be mapped to the local user jschmoe, the address will return the indicated error, the address will be mapped to the local user
     yourdomain-list (which you would use the aliases file to ultimately resolve) and every other user at will be
     mapped to a remote user of the same name at

     Note 1: if you have a local user, say sam, and there is no key for and no catch-all key for, then sendmail will fall back to the local user sam when resolving To prevent this,
     you must use either a catch-all key or an explicit key for; the error:nouser example above may be
     useful in this instance.

     Note 2: if you want a virtual address to resolve to more than one real address, you need to do it indirectly. Have the virtual
     address resolve to a local alias, then have the local alias resolve to the desired set of addresses. For example, in the virtual user
     table:              localjoe

     then in the aliases file:


   5.Build the virtual user table. If the above virtual user table text file is located at sourcefile, and you are using the dbm database
     type, then use the command:

     makemap dbm /etc/virtusertable < sourcefile

     This actually creates one or more non-text files (typically /etc/virtusertable.dir and /etc/virtusertable.pag, or
     /etc/virtusertable.db), but does not actually change /etc/virtusertable itself, so this is the recommended location for

   6.If you would like to reverse-map local users for out-bound mail, you will need to add support for the generics table to your .mc

     FEATURE(`genericstable', `dbm /etc/genericstable')dnl

     And you will need to create /etc/genericstable which is like /etc/virtusertable above except the columns are


     Note: you may also wish to consult our Masquerading and Relaying page.

   7.Add your domain name to sendmail's class w. This is typically done by adding a line to /etc/ with the value of
     your domain name.

     Likewise, if you are using the genericstable, you should add any domains you wish to reverse-map to /etc/sendmail.cG.

   8.Restart or SIGHUP sendmail. Note that you do not need to restart sendmail when changing the virtual user or generics tables, only
     when changing /etc/ or class files such as /etc/
you might want to swith your pop and mta to qmail. easier,quicker,more secure...
zzASLANzzAuthor Commented:
Listen, nobody seems to get what Im saying here.  First off, I really appreciate all your comments, but I know how to setup a DNS.  I don't care how to forward 500 email addresses to one mailbox.  I want to be able to host email for 100 different domains.  I want to be able to have the SAME username for each domain. Let's say a and a and a  But right now, Linux does not let me create more than one joe account.  I have to call one joe, then joe1, joe2.....  I need to offer my customers the ability to have any email address that isn't already used in THEIR DOMAIN, not in any domain I host.      
zzASLANzzAuthor Commented:
How would I go about switching to qmail?  Would it convert all the info I have now.  I have like 150 email accounts setup.
Which linux do you use. I have similar problem in Redhat 6.0.
My problem is that if I have a mail account in /etc/aliases for
instance no other account with name
joe in other domains works as it should. So if I want to use
same name for different domains I can not have that same
name in aliases. Then everything works fine for me. Check
this out, maybe it will help you.
using the technique i described, sendmail's virtusertable maps domains like you want: user1 user2

here both users have an address of 'info' with different domains--the problem you stated.

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
marko, ventolin,  Right!

That's what I meant by aliases.  Not DNS aliases, user aliases (i.e. virtual users).

Sleeping Lion (aka zzASLANzz),

I don't understand why you don't think ventolin has the solution.  Have you tested it?


zzASLANzzAuthor Commented:
It works.  Your right.  Sorry, I am new to Linux and it's frustrating.  I didn't even have an email alias setup, so Linux was defaulting to using just the username.  Once I put in an email alias, I can make &  I just can't have two of the same popuser names.  It's all set, thanks.  Anyone know how to reroute all the mail for root to another email account.  I didn't see the root account listed under pop accounts.  I see how to forward email in the popuser admin tab, but I can't find a way to forward all the stuff that goes to root.  
the easiest way would be to put a file called '.forward' in root's home directory. in the file have one line that has the email address you want to forward it to.

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

From novice to tech pro — start learning today.