Postfix is a mail tranfer agent (MTA) developed by Wietse
Venema. It started out as an IBM project called VMailer. Postfix
has become very popular in the Linux world as an alternative to the
ubiquitous Sendmail program. It's much easier to configure than
Sendmail, whose configuration file has known to provoke nightmares
in small children and rookie systems administrators. For our
system, we'll be compiling a special MySQL enhanced Postfix.
First, Postfix will need a user on the system called 'postfix'
and a group called 'postdrop'. Before you do anything, create this
user and group.
The Postfix source code is available at http://www.postfix.org/download.html. Choose the
latest version, which at the time of this writing is 2.2. Untar the
source in the directory you've chosen to work in. First, we'll
configure the source code to work well with MySQL and SASL. Issue
the following:
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql \
-DUSE_SASL_AUTH -I/usr/local/include/sasl' \
'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2'
|
If you didn't see any errors (and again, you shouldn't), you can
now proceed to compile the postfix binaries. Do:
This could take a while, depending on your hardware. At the end
of the install process, you'll have to answer some questions. The
first one looks like this:
install_root: [/]
Please specify a directory for scratch files while installing Postfix.
You must have write permission in this directory.
tempdir: [/home/mike/mail_system/postfix-2.2]
|
There will be several of these. The default answers should be
fine. If you need to change them, please answer appropriately for
your setup.
Postfix will have created it's configuration files in the usual
place, which is /etc/postfix/. You'll need to open a file called
'main.cf' and make some modifications and additions. I have found
that the easiest way to do this is to search for the lines that
need modifying first and then add the missing lines. The bottom
line is that 'main.cf' should contain the following lines. Modify
and add so that it does.
home_mailbox = Maildir/
recipient_delimiter = +
mydestination = $myhostname, $transport_maps
alias_maps = mysql:/etc/postfix/mysql-aliases.cf
relocated_maps = mysql:/etc/postfix/mysql-relocated.cf
transport_maps = mysql:/etc/postfix/mysql-transport.cf
virtual_maps = mysql:/etc/postfix/mysql-virtual.cf
local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual-uid.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual-gid.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = linux.ork
mydomain = sub.linux.ork
myorigin = $mydomain
unknown_local_recipient_reject_code = 550
debug_peer_level = 2
debugger_command = \
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin \
xxgdb $daemon_directory/$process_name $process_id & sleep 5 \
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/local/man
sample_directory = /etc/postfix
readme_directory = no
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_sasl_authenticated,
reject_unauth_destination
smtpd_sasl_local_domain = $myhostname
|
You'll also need to create these additional files in
/etc/postfix/ so that MySQL and Postfix will work together:
mysql-aliases.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_alias
select_field = destination
where_field = alias
hosts = localhost
|
mysql-client.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_access
select_field = access
where_field = source
additional_conditions = and type = 'client'
hosts = localhost
|
mysql-recipient.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_access
select_field = access
where_field = source
additional_conditions = and type = 'recipient'
hosts = localhost
|
mysql-relocated.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_relocated
select_field = destination
where_field = email
hosts = localhost
|
mysql-sender.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_access
select_field = access
where_field = source
additional_conditions = and type = 'sender'
hosts = localhost
|
mysql-transport.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_transport
select_field = destination
where_field = domain
hosts = localhost
|
mysql-virtual.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_virtual
select_field = destination
where_field = email
hosts = localhost
|
mysql-virtual-gid.cf
user = postfix
password = XXXXXXX
dbname = postfix
table = postfix_users
select_field = gid
where_field = email
additional_conditions = and postfix = 'y'
hosts = localhost
|
mysql-virtual-uid.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_users
select_field = uid
where_field = email
additional_conditions = and postfix = 'y'
hosts = localhost
|
mysql-virtual-maps.cf
user = postfix
password = XXXXXXXX
dbname = postfix
table = postfix_users
select_field = maildir
where_field = email
additional_conditions = and postfix = 'y'
hosts = localhost
|
Finally, we'll need to create a user and group called 'vmail'.
In this system, all of the mail will be stored in /home/vmail. Make
sure this directory exists. If not (depending on how you created
this user), create it and make sure that everything is owned by the
user 'vmail' (chown -R vmail:vmail
/home/vmail).
That's all for now in the Postfix part. Let's now move on to
Courier IMAP.