Installation:Ubuntu:Maildrop
Introduction
On Ubuntu 7.10 Server you need to install the following packages:
- courier-maildrop
- courier-authlib-mysql (mySQL) or
- courier-authlib-postgresql (postgreSQL)
On Ubuntu 7.10 Server use this command to install all at once:
mySQL
apt-get install courier-maildrop courier-authlib-mysql
PostgreSQL
apt-get install courier-maildrop courier-authlib-postgresql
Maildrop is being used for filtering purposes and automated delivery in the appropriate directories.
Configure Maildrop
Maildrop Configurationfile
To avoid a termination with error code Signal 0x0B the configuration-file must be created now. Here you find an example of a typical configuration file.
/etc/courier/maildropmysql.config
hostname localhost socket /var/run/mysqld/mysqld.sock port 3306 database pmwh2 dbuser postfix_user dbpw postfix_password dbtable postfix_users default_uidnumber 5000 default_gidnumber 5000 uid_field email uidnumber_field uid gidnumber_field gid maildir_field maildir homedirectory_field homedir quota_field quota mailstatus_field postfix where_clause AND postfix = 'y'
The privileges of this files are recommended as 600. Keep in mind that it contains the password for pmwh2.
Maildropscript
In order to give a detailed instruction of operation for maildrop we need the file /etc/courier/maildroprc wich contains these instructions.
/etc/courier/maildroprc
# # Import variables # LOGNAME=tolower("$LOGNAME") EXTENSION="$1" RECIPIENT=tolower("$2") USER="$3" HOST="$4" SENDER="$5" DEFAULT="$HOME/$DEFAULT" SPAMDIR="$DEFAULT.Junk-E-Mail/" LOGUSERSETTINGS=1 # # Autocreate logfile, if not existant # `test -e /var/log/mailfilter_log` if ( $RETURNCODE != 0 ) { `touch /var/log/mailfilter_log` } logfile "/var/log/mailfilter_log" if ( "$EXTENSION" ne "" ) { DELIMITER="+" } if (!$SENDER) { SENDER = "<>" } # # Autocreate maildir, if not existant # `test -e $DEFAULT` if ( $RETURNCODE != 0 ) { `/bin/mkdir -p $DEFAULT` `/bin/rmdir $DEFAULT` if ( $MAILDIRQUPTA != ) { `/usr/bin/maildirmake.courier -q $MAILDIRQUOTA $DEFAULT` } else { `/usr/bin/maildirmake.courier $DEFAULT` } } else { if ( $MAILDIRQUOTA != ) { `/usr/bin/maildirmake.courier -q $MAILDIRQUOTA $DEFAULT` } else { `test -e $DEFAULT/maildirsize` if ( $RETURNCODE == 0 ) { `rm $DEFAULT/maildirsize` } } } # # Check that user has his own maildrop include, # if not available, check if $DEFAULT is set # (newer maildrop get's that from the DB and updates # it) and deliver or fail temporarily if not available # `test -f $HOME/.mailfilters/$LOGNAME` if ( $RETURNCODE == 0 ) { include "$HOME/.mailfilters/$LOGNAME" } if ( /^X-Spam-Flag: YES/ ) { `test -d $SPAMDIR` if ( $RETURNCODE == 1 ) { `maildirmake $SPAMDIR` } exception { to $SPAMDIR } } else { if ( "$DEFAULT" ne "" ) { exception { to "$DEFAULT" } } else { EXITCODE=75 exit } }
Postfix-Adjustments
To let postfix know, that mails are forwarded to maildrop instead of using the own virtual-daemon the adjustments below need to be done. The value of the variable virtual_transport will be switched from virtual into maildrop
bash#> sudo postconf -e 'virtual_transport = maildrop' bash#> sudo postconf -e 'maildrop_destination_concurrency_limit = 1 bash#> sudo postconf -e 'maildrop_destination_recipient_limit = 1
Postfix also needs to know where exactly the target maildrop is located. It will be done by an adjustment of the file /etc/postfix/master.cf The original file should already contain an out-commented Line for maildrop Please note the whitespaces in the second and third line. Postfix is quite sensitiv regarding the syntax of master.cf
/etc/postfix/master.cf
maildrop unix - n n - - pipe flags=R user=vmail argv=/usr/bin/maildrop -d ${user}@${nexthop} ${extension} ${recipient} ${user} ${nexthop} ${sender}
Configuration of Maildrop is done. next step