Setting up Postfix and Dovecot with virtual mailboxes

Postfix

# groupadd -g 1000 virtual
# useradd -M -u 1000 -g virtual -s /sbin/nologin -d /var/mail/vhosts virtual

virtual_mailbox_domains = example.com, example.net
virtual_alias_maps = hash:/etc/postfix/virtual_alias
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000

# mkdir /var/mail/vhosts

# mkdir /var/mail/vhosts/example.com
# mkdir /var/mail/vhosts/example.net

# mkdir /var/mail/vhosts/example.com/bob

# Comment out the entry below to implement a catch-all.
# @example.com      example.com/catchall

# Remember the trailing slash for Maildir format!

# example.com
bob@example.com   example.com/bob/

# example.net
alice@example.net example.net/alice/

Dovecot

The dovecot RPM has a MySQL dependency. This can be a problem if you use the MySQL official RPMs because they have a different name from the Fedora supplied RPMs. To get around this I modified the src RPM spec file and rebuilt the RPM to use the MySQL official RPMs (and I also removed PostgreSQL support):

# rpm -Uvh dovecot-1.0-3_51.rc28.at.src.rpm

%define build_postgres 0

BuildRequires: MySQL-devel

# rpmbuild --without inotify -ba dovecot.spec
# rpm -Uvh dovecot-1.0-3_51.rc28.i386.rpm

mail_location = maildir:/var/mail/vhosts/%d/%n

# passwd-like file with specified location
# http://wiki.dovecot.org/AuthDatabase/PasswdFile
passdb passwd-file {
  # Path for passwd-file
  args = /etc/dovecot/passwd
}

# passwd-like file with specified location
# http://wiki.dovecot.org/AuthDatabase/PasswdFile
userdb passwd-file {
  # Path for passwd-file
  args = /etc/dovecot/users
}

foo@example.com:{md5}dhf83jS64hgowkgj34jdhfjsdf

foo@example.com::1000:1000::/var/mail/vhosts/example.com/:/bin/false::


CategoryLinux

PostfixDovecotVirtual (last edited 2007-03-29 21:10:23 by DavidKeen)