Home
|
Mini-Howtos & Tutorials
Configure mail virtual hosts with the Postoffice SMTP Daemon
Pierre-Philipp Braun <pbraun@nethence.com>
Introduction
mbox may be the most convenient mailbox format, it's just bare text files. Combined with virtual hosts, we also establish a clean cut separation between the domains, and users.
POP is a nice protocol for users, it may even be used somehow like IMAP : configure your client to keep the messages on the server and remove if deleted from INBOX. You keep a full copy of the message locally and it only fetches the mail once; much lighter than IMAP.
Note. Postoffice compiles fine on NetBSD/sparc64 since 1.2.0 and 1.3.pre1 fixed the mail/aliases path. No additionnal tweeks are needed since then.
Prepare the system
Check if mail user and group exist. Note the shell should be /sbin/nologin,
grep mail /etc/passwd
grep mail /etc/group
If they don't exist, create them,
groupadd mail
useradd -g mail -s /sbin/nologin mail
Then prepare directories and permissions,
mkdir /var/spool/virtual
mkdir /var/spool/mqueue
mkdir /etc/virtual
chown mail:mail /var/spool/virtual
chown mail:mail /var/spool/mqueue
chown mail:mail /etc/virtual
chmod 700 /var/spool/virtual
chmod 700 /var/spool/mqueue
chmod 700 /etc/virtual
Install vm-pop3d
Untar the tarball and,
./configure --help
./configure --enable-virtual
make clean
make
su
make install
Start the daemon,
/usr/local/sbin/vm-pop3d -umail -gmail -d2
Install postoffice
Check for those dependencies,
- ndbm or gdbm (on RHEL add gdbm-devel)
- tcpwrappers (eventually)
Untar the tarball and,
./configure.sh --help
./configure.sh \
--with-auth \
--with-milter \
--with-vhost=/etc/virtual \
--with-vspool=/var/spool/virtual \
--with-vuser=mail
make clean
make
su
make install
Note if you like to enable non virtual host AUTH LOGIN, also add,
--with-auth=passwd
Those options may also be worth mentioning but I don't use them,
--use-mailwrappers \
--with-tcpwrappers \
--with-greylist \
Note. --with-auth does SMTP Authentication, AUTH LOGIN. No need for cyrus-sasl kluges & pain like other SMTP servers do. No configuration is needed, it just works for virtual host users even.
Note. this was alright for Postoffice 1.2.x and 1.3.x. Maybe there some new relevant options. Check with,
./configure --help
Update mailwrapper's config,
vi /etc/mailer.conf
And eventually,
cd /usr/bin
mv mailq mailq.old
ln -s /usr/local/bin/mailq
Configure Postoffice
Edit Postoffice's configuration,
vi /etc/postoffice.cf
For example
self=mx.example.com
audit
clients=30
delay=1m
hops=3
minfree=400m
size=10m
timeout=1h
escape-from=1
Check the manuals for other options.
As for milters, here's two examples,
filter=/path/to/unix.socket
filter=hostname:port
Edit the global aliases and update the alias table,
vi /etc/mail/aliases (or /etc/aliases, eventually link one to another)
newaliases
Start the daemon,
/usr/local/lib/postoffice -C/etc/postoffice.cf -bd -q2
Note. you can put a higher or lower value than 2 minutes (-q2) for the queue processing interval.
This magnificiently results in two processes (do ps aux):
postoffice: postoffice: accepting connections
postoffice: postoffice: runq every 2 minutes
To check queue,
mailq
To check current SMTP sessions,
ps aux | grep postoffice
To force the immediate processing of the queue,
runq
Edit the virtual hosts,
vi /etc/virtual/domains.cf
Edit password files with pop_passwd.pl or vpasswd
pop_passwd.pl username password >> example.com/passwd
vi example.com/aliases
newaliases example.com
MX records & name resolution
Note. Postoffice skips /etc/hosts and system DNS resolution. It has its own.
Virtual vs non-Virtual
Note. If the receiving message is for another domain than those listed in domains.cf, namely the virtual ones, it will accept them locally as long as the MX record matches or is empty.
Note. When doing SMTP through telnet, you need to embrace the IP like,
rcpt to:user@[XX.XX.XX.XX]
Troubbleshooting
Check you got the latest version,
/usr/local/lib/postoffice -V
Check the postoffice running processes,
ps aux | grep post
ps aux | grep runq
Check and run the queue,
mailq
cd /var/spool/mqueue/
ls -l
ps aux | grep post
ps aux | grep runq
runq
Find out what's using /var/spool/mqueue (in case it's not even a lying runq process),
lsof | grep mqueue
Migrating the whole service to another server
When migrating the SMTP service from one server to another (not mentioning the DNS matters),
cd /var/spool
ls -l mqueue # should be empty. Otherwise do mailq
tar czpf /root/virtualVAR.tar.gz virtual
cd /etc
tar czpf /root/virtualETC.tar.gz virtual
Send both to your new server, check /etc/mailer.conf, /etc/aliases (or /etc/mail/aliases),
and refresh the alias tables,
newaliases
newaliases example.com
Links
Page generated Mon Aug 18 12:05:30 CEST 2008
html/
css
Pierre-Philipp Braun <pbraun@nethence.com>
BSD Documentation Licence