Hi all,
I would like to set up mail filtering on a postfix server. I have read a
lot of documentation, but I can't make it works.
Here's what I did :
- install maildrop package (should I use maildrop or courier-maildrop ?)
- create /etc/maildroprc
- set maildrop transport in master.cf :
maildrop unix - n n - - pipe
flags=ODRhu user=www-data argv=/usr/bin/maildrop -d
${us...@${nexthop} ${extension} ${recipient} ${user} ${nexthop} ${sender}
- setuid / setgid on maildrop binary, chown
- add conf to main.cf :
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
The problem is that maildrop seems to never been invoked. Postfix choose
local to deliver the mail, but I can't find why. I would like it uses
maildrop instead.
I join postconf -n, maildroprc, and a log extract showing the problem.
Any idea ?
Regards,
Ben
Dec 1 17:29:25 kappa postfix/smtpd[15348]: connect from localhost.localdomain[127.0.0.1]
Dec 1 17:29:25 kappa postfix/smtpd[15348]: F312149226: client=localhost.localdomain[127.0.0.1]
Dec 1 17:29:26 kappa postfix/cleanup[15344]: F312149226: message-id=<aanlktimuiuygafo7hh5k0ku-jmt23m4lmnqzaxugm...@mail.gmail.com>
Dec 1 17:29:26 kappa postfix/qmgr[11376]: F312149226: from=<b...@gmail.com>, size=6650, nrcpt=1 (queue active)
Dec 1 17:29:26 kappa postfix/smtpd[15348]: disconnect from localhost.localdomain[127.0.0.1]
Dec 1 17:29:26 kappa amavis[14733]: (14733-02) Passed CLEAN, [74.125.83.43] [74.125.83.43] <b...@gmail.com> -> <test_domain....@mx1.hoster.com>, Message-ID: <aanlktimiuygafo7hh5k0ku-jmt23m4lmnqzaxugm...@mail.gmail.com>, mail_id: mxFjSqU-it1e, Hits: -1.225, queued_as: F312149226, 6422 ms
Dec 1 17:29:26 kappa postfix/smtp[15345]: 636F7491E7: to=<test_domain....@mx1.hoster.com>, orig_to=<t...@domain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=6.8, delays=0.35/0.01/0/6.4, dsn=2.6.0, status=sent (250 2.6.0 Ok, id=14733-02, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as F312149226)
Dec 1 17:29:26 kappa postfix/qmgr[11376]: 636F7491E7: removed
Dec 1 17:29:26 kappa postfix/local[15349]: F312149226: to=<test_domain....@mx1.hoster.com>, relay=local, delay=0.1, delays=0.05/0.01/0/0.04, dsn=2.0.0, status=sent (delivered to maildir)
Dec 1 17:29:26 kappa postfix/qmgr[11376]: F312149226: removed
$ postconf -n
alias_maps = mysql:/etc/postfix/myalias.cf hash:/etc/aliases
body_checks = regexp:/etc/postfix/body_checks
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
content_filter = smtp-amavis:[127.0.0.1]:10024
daemon_directory = /usr/lib/postfix
default_destination_concurrency_limit = 10
default_privs = www-data
disable_vrfy_command = yes
header_checks = regexp:/etc/postfix/header_checks
home_mailbox = Maildir/
local_destination_concurrency_limit = 8
mail_owner = postfix
mailbox_command = maildrop
message_size_limit = 20480000
myhostname = mx1.hoster.com
mynetworks = 127.0.0.1 91.xxx.xxx.xxx 91.xxx.xxx.xxx
myorigin = mx1.hoster.com
queue_directory = /var/spool/postfix
smtp_tls_CApath = $smtpd_tls_CApath
smtp_tls_dcert_file = $smtpd_tls_dcert_file
smtp_tls_dkey_file = $smtpd_tls_dcert_file
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP
smtpd_helo_required = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_invalid_hostname, reject_non_fqdn_hostname, reject_non_fqdn_sender,
reject_non_fqdn_recipient, reject_unknown_recipient_domain,
reject_unauth_pipelining, reject_unauth_destination, reject_rbl_client
cbl.abuseat.org, reject_rbl_client sbl.spamhaus.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = postfix
smtpd_sasl_security_options = noanonymous
smtpd_tls_CApath = /etc/ssl/certs/
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = $smtpd_tls_dcert_file
smtpd_tls_dcert_file = /etc/ssl/private/ssl.mx1.hoster.com.pem
smtpd_tls_dkey_file = $smtpd_tls_dcert_file
smtpd_tls_key_file = $smtpd_tls_dcert_file
smtpd_tls_loglevel = 0
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
virtual_gid_maps = proxy:mysql:/etc/postfix/mygid.cf
virtual_mailbox_base = /
virtual_mailbox_maps = proxy:mysql:/etc/postfix/myvirtual.cf
virtual_minimum_uid = 1000
virtual_transport = maildrop
virtual_uid_maps = static:33
# Global maildrop filter file
# Uncomment this line to make maildrop default to ~/Maildir for
# delivery- this is where courier-imap (amongst others) will look.
#DEFAULT="$HOME/Maildir"
VERBOSE="5"
logfile "/var/log/maildroprc.log"
# commands and variables for making the mail directories
maildirmake=/usr/bin/maildirmake
mkdir=/bin/mkdir
rmdir=/bin/rmdir
MAILDIR=$DEFAULT
# make the user's mail directory if it doesn't exist
#`test -e $MAILDIR`
#if ($RETURNCODE != 0)
#{
#`$mkdir -p $MAILDIR`
#`$rmdir $MAILDIR`
#`$maildirmake $MAILDIR`
#}
`echo " -> "$MAILDIR $DEFAULT >> /tmp/md.log`
# make the .Junk folder if it doesn't exist
JUNK_FOLDER=.Junk
_JUNK_DEST=$MAILDIR/$JUNK_FOLDER/
`test -d $_JUNK_DEST`
if ($RETURNCODE != 0 )
{
`$maildirmake $_JUNK_DEST`
#auto subscribe. the following works for courier-imap
`echo INBOX.Junk >> $MAILDIR/courierimapsubscribed`
}
# If the Spam-Flag is set, move the mail to the Junk folder
if (/^X-Spam-Flag:.*YES/)
{
exception {
to $DEFAULT/.Junk/
}
}