Integrating vpopmail into postfix

Posted on September 29th, 2008

Migration always involves lots of work... And in the end things tend to break anyways! ;-)

So, sometimes it might be smart to accept a little overhead and just add to already running systems instead of redoing everything. This is one of those times!

I had to install Postfix on a customers mail-server which had previously been running qmail and vpopmail for virtual domains. The only bit of information i could find is this: http://www.inter7.com/vpopmail/postfix.txt

(Install postfix into a non-standart prefix, to make sure you dont overwrite any of qmail's files)

Now... That allows you to hand off all mails to qmail after accepting them into the postfix queue. So everything works as previously, just that there's a mighty postfix running on port 25! :-)

There's only 2 little problems with that setup:

  • autenticated sending of mails needs to be configured in postfix now, this can get tricky if you want to migrate lots of accounts
  • making sure mail for non-existant recipients is rejected instead of bounced, so your server doesnt end up being a source for backscatter

For the second problem i wrote just a tiny shell-script, which you might find helpful:

#!/bin/bash

echo "#########################################################" > /etc/postfix/local_recipients
echo "#" >> /etc/postfix/local_recipients
echo "# WARNING: auto-generated file, any changes will be lost!" >> /etc/postfix/local_recipients
echo "#" >> /etc/postfix/local_recipients
echo "#########################################################" >> /etc/postfix/local_recipients
echo "" >> /etc/postfix/local_recipients
echo "" >> /etc/postfix/local_recipients

for I in `find /home/vpopmail/domains/ -mindepth 1 -maxdepth 1 -type d`; do
        DOMAIN=`basename $I`
        if [ -f "$I/.qmail-default" ]; then
                echo -e "@$DOMAIN\tpermit"  >> /etc/postfix/local_recipients
        else
                for J in `find $I -mindepth 1 -maxdepth 1 -type d`; do
                        echo -e "`basename $J`@$DOMAIN\tpermit"  >> /etc/postfix/local_recipients
                done
                for J in "$I/.qmail-*"; do
                        echo "WARNING: alias $J not processed!!"
                done
        fi
done

/opt/postfix/sbin/postmap /etc/postfix/local_recipients

This doenst handle aliases yet and the paths would have to be adjusted obviously!

You can then put this entry into /etc/postfix/main.cf:

local_recipient_maps = hash:/etc/postfix/local_recipients

Postfix picks up changes to its maps without being restarted, so you can put this in cron.hourly and have all changes to accounts reflected within an hour max or just run it manually after you changed something!

:-)

AddThis button



About Me

Photo of myself Aike J Sommer
web [at] aikesommer [dot] name
Feed: RSS Syndicate content
Company: AS Media

Services / Products