Thanks for a great tutorial, Flurdy!
I have managed to complement Flurdy's tutorial such that virtual transport is swapped for maildrop and spam is automatically delivered to a spam folder.
It is based on the excellent tutorial by Flurdy and complemented by parts of the tutorial found here:
http://daemonforums.org/showthread.php?t=193
The latter tutorial also contains methods to implement vacation messaging.
If in doubt, check out the forementioned tutorial.
Here's what I did:
Complete Flurdy's tutorial and install maildrop
uncomment in main.cf:
Code:
transport_maps = mysql:/etc/postfix/mysql_transport.cf
and add
Code:
maildrop_destination_recipient_limit = 1
Master.cf file should contain the following line, change the user field to virtual:
Code:
maildrop unix - n n - - pipe
flags=DRhu user=virtual argv=/usr/bin/maildrop -d ${recipient}
create mysql_transport.cf file and set the correct owner and permissions:
Code:
user=mail
password=changeme
dbname=maildb
table=domains
select_field=transport
where_field=domain
hosts=127.0.0.1
additional_conditions = and enabled = 1
create:
Code:
# cd /var/spool/mail/virtual/
# chmod +s /usr/bin/maildrop
# touch .mailfilter
# chmod 600 .mailfilter
# mkdir mailfilters
# chmod 700 mailfilters
# chown -R virtual:virtual .mailfilter mailfilters
test maildrop and check logs:
Code:
echo "test" | maildrop -V 9 -d you@example.com
Edit the ...virtual/.mailfilter file (haven't tested this bit):
Code:
# Deliver to Inbox or Spam box (create spam box if it does not exist)
if (/^X-Spam-Flag: YES/:h)
{
`test -d $DEFAULT/.junkmail`
if ($RETURNCODE == 1)
{
`/usr/bin/maildirmake -f junkmail $DEFAULT`
`echo "junkmail" >> $DEFAULT/subscriptions`
}
exception {
to "$DEFAULT/.junkmail"
}
# if all else fails, do regular delivery
exception {
to "$DEFAULT"
}
}
Now use phpmyadmin and change domain transport field from "virtual:" to "maildrop:"
Restart postfix, check log files and pray
Much of the code here is curtesy of hamba from daemonforums.org
Hope this helps!
Cheers, Villu
Bookmarks