multiple domain names and email addresses

Heya all..

I have a mail server here with more than one domain name.
I want to be able to receive email via info@domainname.com for each domain.  at the moment, they all goto the main domain name.  How do I setup virtual domain emails?  even if it's just aliasing of some kind.  what is the best way to do this?
LVL 1
Q010797Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dirgeConnect With a Mentor Commented:
Well, then, that's the problem. It looks like your sendmail.cf configuration isn't setup properly for virtual domains.

Putting "info@domain1.com info-1" in the /etc/aliases file is NOT good enough. You need to create an /etc/virtusertable.db (or .dir/.pag, whatever) database containing the virtual domain mappings. READ THROUGH BEFORE TRYING.

Step 1. Create "info-1", "info-2", etc. accounts, to be used for each domain.

Step 2. cd to /etc. Create /etc/virtusertable as a text file like so:

info@domain1.com  info-1
info@domain2.com  info-2
info@domain3.com  info-3

Step 3. Run "makemap hash /etc/virtusertable" or "makemap dbm /etc/virtusertable" ("hash" is more or less available on all Linux systems)

If you don't have makemap ("locate makemap", "which makemap") on your system, try this quick-and-dirty Perl script that simulates "makemap hash":

#!/usr/bin/perl
# Edit first line to point to your perl binary

use AnyDBM_File;

open(FILE,"/etc/virtusertable");
dbmopen(%vusers,"/etc/virtusertable",0644);
while(chomp($line=<FILE>)) {
   next if ($line eq "") || $line=~/^\#/;
   ($addr,$user)=split(" ",$line);
   $vusers{$addr}=$user;
}
dbmclose(%vusers);
close(FILE);

Step 4. Edit sendmail.cf as follows:

4a. If you used "hash" (or the script) above, use the line

Kvirtuser hash /etc/virtusertable

Use "dbm" instead of "hash" if you successfully managed to use "makemap dbm"

4b. Make sure that you have lines in your sendmail.cf analogous to:

# handle virtual users
R$+ < @ $=w . >         $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @ $2 . >
R<@> $+ + $* < @ $* . > $: < $(virtuser $1 + * @ $3 $@ $1 $: @ $) > $1 + $2 < @ $3 . >
R<@> $+ + $* < @ $* . > $: < $(virtuser $1 @ $3 $@ $1 $: @ $) > $1 + $2 < @ $3 . >
R<@> $+ < @ $+ . >      $: < $(virtuser @ $2 $@ $1 $: @ $) > $1 < @ $2 . >
R<@> $+                 $: $1
R< error : $- $+ > $*   $#error $@ $(dequote $1 $) $: $2
R< $+ > $+ < @ $+ >     $: $>97 $1

Tabs separate the left and right sides ($:, $#) of the lines, not spaces.

5. Edit your /etc/sendmail.cw file (assuming there is a line like "Fw/etc/sendmail.cw" in your sendmail.cf) to contain all the domain names, one per line.

6. Send a HUP signal to sendmail, e.g. "kill -HUP `cat /var/run/sendmail.pid`" (assuming there IS a /var/run/sendmail.pid. If not, "ps ax | grep sendmail", choose lowest PID to kill -HUP. Also, those are backticks, not single quotes.) Sorry if you already know this, but it seemed best to be sure.

Try it. If it doesn't work, you may be having any of the following problems:

a. If you're getting "Mail loops back to me":

  - MX entries (in your DNS) may not be setup properly
  - You may need to add/uncomment "Djyourdomain.com" in your sendmail.cf

b. Sendmail tries to optimize by considering email to a domain that resolves to the same physical machine as belonging to the "root" domain. SOLUTION: you may have to patch sendmail especially since you are not using the latest version. Leave a comment here if you need the patch (I'll have to look for it.) ALTERNATIVE: Upgrade to sendmail 8.9.x and uncomment/add "DontProbeInterfaces" to your sendmail.cf.

Don't forget to restart sendmail.

If you really want to have "info" as the POP/IMAP username on all domains, you'll have to go through the trouble of either using virtuald (see Linux Virtual Services HOWTO), or creating a specialized mailer for sendmail and patching your POP3 daemon.

I hope this helps...
0
 
RoboBobCommented:
If you are using sendmail as your mail server, there are instructions for setting up virtual domains at http://www.sendmail.org/virtual-hosting.html
0
 
Q010797Author Commented:
That's a little more of a complicated answer than I wanted.  Can't you just give me some example files and what to type where and how?
0
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

 
RoboBobCommented:
Its a complicated answer because its a complicated question, any example configuration would have to be modified to fit your specific installation anyway...
0
 
Q010797Author Commented:
well can you give me an example config that all I have to do is put the domain in the right spot?  you already know I only have 2 domains and want the examples with sendmail 8.8.8 and linux 2.0
0
 
bryanjonesCommented:
The best way to do this is placing each and every domainname in the sendmail.cw file.

EXAMPLE: .....
idiot.com
killer.com
boo.com

All these entries in the sendmail.cw file
0
 
Q010797Author Commented:
that's not what I want.  I want (on the same mail server) the two email addresses kept seperate

info@domain1.com
info@domain2.com

how do I do this?
0
 
feenixCommented:
One solution is the following:
Create accounts info-1, info-2, info-3 etc. Then write to /etc/mail/aliases (or where ever that file is in your system) the following lines:
info@domain1.com:  info-1
info@domain2.com:  info-2
info@domain3.com:  info-3
etc for all the domains. Then run newaliases and you're done. All the different domains should have separate info-account.
0
 
Q010797Author Commented:
nah that was the FIRST thing I tried... the mail arrives in the info@domain1 account no matter which one I try and send it to.
0
 
dirgeCommented:
Hi, again, Q. Please provide the ff:

1. Sendmail version (I suggest using 8.9.x as it has some stuff to make this easier)

2. Does your /etc/sendmail.cf contain something like:

  Kvirtuser hash -o /etc/virtusertable

? If so you're halfway there. If not, well, you really ought to check out the URL RoboBob provided. (Actually you should read it in any case...)

3. Do you have different IPs for the domains? If so, do you have DontProbeInterfaces setup as an option in your sendmail.cf?

I may have a few more questions depending on your answers to these. All for now...!
0
 
Q010797Author Commented:
am using sendmail 8.8.8

no it doesn't have the above Kvirtuser line.  The only Kvirtuser line is :

#Kvirtuser dbm /etc/virtusertable
as you can see it's # out anyway.

The domains all share the same IP range.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.