There are two ways email can be received into the qmail system
1) smtp
2) qmail-queue
1) incoming email from the net gets read into qmail-smtpd.
a) It looks at /var/qmail/control/rcpthosts. If the domain
is listed, it queues it to disk.
b) If not listed and the
RELAYCLIENT environment variable is set, it will queue it
to disk.
2) qmail-queue is invoked by a local program.
a) sendmail wrapper
b) qmail-inject
In all cases, it is queued to disk
3) qmail-send decides if it is a local delivery or a remote delivery.
a) We only care about local deliveries. This is done by qmail-send
looking for the email domain in /var/qmail/control/rcpthosts. If
it is in there, it hands the email to qmail-lspawn.
b) If it is not in /var/qmail/control/rcpthosts it hands the email
of to qmail-rspawn for remote delivery.
3) qmail-lspawn forks/execs qmail-local
qmail-lspawn manages the concurrent qmail-local programs, and
fork/execs a new one for each mail.
4) qmail-local starts to deliver the message.
a) Looks in /var/qmail/control/local for the domain. If found
it looks up the user in /etc/passwd and attempts delivery.
b) OUR CASE: not found in /var/qmail/control/local. It then
looks in /var/qmail/control/virtualdomains for any name
re-writing. In vpopmail case, the name is the same as the domain.
c) look in /var/qmail/users/cdb (the compiled version of
/var/qmail/users/assign) for the domain name.
d) If found (vpopmail case), then change uid/gid to the uid/gid
listed in the file and changed directory to the directory listed
in the file.
e) qmail-local looks for a .qmail-user file. If found, follows
the instructions there. (not vpopmail way except for aliases and
forwards) NOTE: Future versions of vpopmail will contain alias
and forward lookups)
f) If qmail-local can not find a .qmail-user file, it looks for
a .qmail-default file (this is the vpopmail way).
g) .qmail-default contains "| /path/to/vdelivermail `` option
where option can be:
1) bounce-no-mailbox
2) an email address
3) path to a maildir directory
h) vdelivermail is fork/exec'd by qmail-local
i) vdelivermail looks up user information by calling vpopmail
library call vauth_getpw(). This returns NULL if the user does
not exist, or returns a password structure, with the users
Maildir.
j) if quota support is compiled in, it checks the current Maildir
new, cur, tmp file sizes, adds in the new message size and checks
it against the quota field (pw_shell).
1) if over quota, return to sender
2) if under quota, write to Maildir/new
k) if no quota support, write to users Maildir/new
Done.
As you can see from the above, vdelivermail is used to lookup a users
directory and quota information. It saves on having to have a
.qmail-user
file for every user, and allows for other processing (quotas for
example).
In contrast with qmail-local delivery via .qmail-user files, there is
no quota checking.
As system admin's, we have the flexibility to use both qmail-local
processing and the optimizations of vdelivermail. We can mix and
match them as we please.
Ken Jones