Maildrop is a Mail delivery agent used by Mail Servers mostly for its filtering functionality. Maildrop reads a mail message from standard input, then delivers the message to your mailbox.
Mailserver installation can be followed from the links below ..
postfix-dovecot
Here I will explain how to configure maildrop with postfix for filering SPAM mails to Junk folder.
First we need to install Perl Compatible Regular Expression software with utf8 support.
For that download the package from the link below,
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.zip
unzip pcre-8.33.zip
cd pcre-8.33
./configure --enable-utf
make
make install
Now download the Maildrop package from the link below,
wget http://jaist.dl.sourceforge.net/project/courier/maildrop/2.7.0/maildrop-2.7.0.tar.bz2
tar -jxvf maildrop-2.7.0.tar.bz2
cd maildrop-2.7.0
./configure
make
make install
Create the configuration file maildroprc,
vim /etc/maildroprc
# commands and variables for making the mail directories
# log the maildrop actions
VERBOSE=9
logfile "/var/log/maildrop.log"
#
# parameters 1, 2 are the domain, user.
DOMAIN=tolower("$1")
USER=tolower("$2")
DEFAULT="/home/vmail/$USER@$DOMAIN/"
##/home/vmail/ is my maildirectory path, Change accordingly.
maildirmake=/usr/local/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`
}
# 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.
`echo Junk >> $MAILDIR/subscriptions`
}
# Filtering, pcre with utf8 support is required
if (/^X-Spam-Flag:.*YES/)
{
exception {
to $DEFAULT/.Junk/
}
}
:wq
Create the log file and give enough privilege,
touch /var/log/maildrop.log
chown dovecot /var/log/maildrop.log (dovecot is the user with which we are running the maildrop)
Now integrate maildrop with postfix,
vim /etc/postfix/master.cf
maildrop unix - n n - - pipe
flags=DRhu user=dovecot argv=/usr/local/bin/maildrop -d dovecot ${nexthop} ${user}
vim /etc/postfix/main.cf
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
Restart postfix
/etc/init.d/postfix restart
Now test your setup by sending a SPAM mail to your server. It will automcatically filter to the .Junk folder in your maildir.
Thanks for reading,
Cheers/-
Mailserver installation can be followed from the links below ..
postfix-dovecot
Here I will explain how to configure maildrop with postfix for filering SPAM mails to Junk folder.
First we need to install Perl Compatible Regular Expression software with utf8 support.
For that download the package from the link below,
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.zip
unzip pcre-8.33.zip
cd pcre-8.33
./configure --enable-utf
make
make install
Now download the Maildrop package from the link below,
wget http://jaist.dl.sourceforge.net/project/courier/maildrop/2.7.0/maildrop-2.7.0.tar.bz2
tar -jxvf maildrop-2.7.0.tar.bz2
cd maildrop-2.7.0
./configure
make
make install
Create the configuration file maildroprc,
vim /etc/maildroprc
# commands and variables for making the mail directories
# log the maildrop actions
VERBOSE=9
logfile "/var/log/maildrop.log"
#
# parameters 1, 2 are the domain, user.
DOMAIN=tolower("$1")
USER=tolower("$2")
DEFAULT="/home/vmail/$USER@$DOMAIN/"
##/home/vmail/ is my maildirectory path, Change accordingly.
maildirmake=/usr/local/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`
}
# 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.
`echo Junk >> $MAILDIR/subscriptions`
}
# Filtering, pcre with utf8 support is required
if (/^X-Spam-Flag:.*YES/)
{
exception {
to $DEFAULT/.Junk/
}
}
:wq
Create the log file and give enough privilege,
touch /var/log/maildrop.log
chown dovecot /var/log/maildrop.log (dovecot is the user with which we are running the maildrop)
Now integrate maildrop with postfix,
vim /etc/postfix/master.cf
maildrop unix - n n - - pipe
flags=DRhu user=dovecot argv=/usr/local/bin/maildrop -d dovecot ${nexthop} ${user}
vim /etc/postfix/main.cf
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
Restart postfix
/etc/init.d/postfix restart
Now test your setup by sending a SPAM mail to your server. It will automcatically filter to the .Junk folder in your maildir.
Thanks for reading,
Cheers/-
No comments:
Post a Comment