Here is a step-by-step explanation.
There is nothing special to do on the POP user side, which is a good thing(tm): We want to merge several email servers into one box, we don't want to tell everyone about it :-)
The trick to reading the mail is exactly the same as with virtual WWW: you need IP addresses. Here is most of the setup. Suppose we want to create three virtual email domains: va.foo.com, vb.foo.com, vc.foo.com. Think about it in the same way as you would do for installing three independent servers, each serving one single email domain. This is what we will describe here and at the end, we will show how these three servers can be merged into a single machine.
From a DNS standpoint, we have one email server per domain. So the MX of each domain is
With the DNS, this is what we are telling the world. This is also what we are telling to email users. Mostly va.foo.com users, get your mail at mailhost.va.foo.com, vb.foo.com users, get your mail at mailhost.vb.foo.com and so on.
So far, with such a setup, we could very well have one server (the real one) per email domain (The current status quo before the virtual email domain is set up).
To continue the setup (be it real or virtual), we edit the DNS and allocate an IP number for each server (this is the key). Here I am using private IP numbers as an example. One will see that I have allocated IP numbers from the same network.
Then we could install three Linux servers with these IPs and tell sendmail on each server to accept one of the three domains.
Instead of installing three Linux servers, we install a single one. For each virtual email domain, we must
"networking/IP aliases for virtual hosts"
The IP alias is the key. The POP protocol has no way to identify the target of a request, except with the IP destination number. This is why POP clients must use a different name (a different IP in fact) to read the messages from different email domains. From their point of view, this is expected anyway.
If you must share an IP address for multiple email domains, the user would still set up their POP client to connect to mailhost.va.foo.com but their username login would no longer be "joe" but "joe@mailhost.va.foo.com". This workaround is a little confusing to some users, but will avoid requiring a separate IP address for every email domain.
Is vpop3d a replacement for the standard POP daemon you are using
on your distribution? Maybe not. Various distributions ship with
different pop3d's, supporting NIS
, PAM
and other authentication
features. The best way to support all these easily is to let the
native pop3d daemon handle the main email domain; vpop3d only
manages the virtual ones.
To get this result, simply pass, as an argument to vpop3d, the path
of the native pop3 daemon. Vpop3d will give itself control when a POP
request is made to the main domain. Here is an example of how to
set /etc/inetd.conf
:
pop-3 stream tcp nowait root /usr/sbin/tcpd
/usr/lib/linuxconf/lib/vpop3d /usr/sbin/ipop3d
So, to install it, do not replace the pop3d command, but simply insert
/usr/lib/linuxconf/lib/vpop3d
. The exact line varies a little
from distribution to distribution.
After installing the package imap, edit the file /etc/xinetd.d/ipop3 and modify the line server and disable, and insert the line server_args. The file will look like this:
service pop3
{
socket_type = stream
wait = no
user = root
server = /usr/lib/linuxconf/lib/vpop3d
server_args = /usr/sbin/ipop3d
log_on_success += USERID
log_on_failure += USERID
disable = no
}