Showing posts with label Postfix. Show all posts
Showing posts with label Postfix. Show all posts

Saturday, January 14, 2012

Server Side Spam Filtering with Postfix Spamassasin and Maildrop


Server Side Filtering spam in Postfix to move all spam tagged mails to a user spam / junk folder is pretty simple.
This solution helps in moving all ***** SPAM ***** subject tagged by spamassasin to be moved to junk folder there by the spam tagged mails doesnt appear in INBOX.
Install Maildrop and configure as given below to automatically move those files to a Junk folder.
Steps to set this with Postfix and Spamassassin :-
First, setup your /etc/maildroprc file:
# 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`
}
# 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/
}
}
The comments clearly state what’s going on there.
Once that’s setup, check /etc/postfix/master.cf and make sure the
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
is not commented out.
Next set the /usr/bin/maildrop file setuid root. This is so maildrop can interact with authdaemon and the mail folders.
#chmod +s /usr/bin/maildrop
Then add this to /etc/postfix/main.cf file:
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
If there is another virtual_transport line, be sure to comment that out first.
Last, set the permissions on the authdaemon so that maildrop can access it.
chown vmail /var/run/courier/authdaemon


Monday, January 9, 2012

Zimbra SSL Certificate expiry downs LDAP

zimbra shows error when i tried to start.

Unable to determine enabled services from ldap.

Unable to determine enabled services. Cache is out of date or doesn't exist.

The reason was i installed SSL with a validity of 365 year ago and forgot to regenerate.
LDAP doesnt start with a expired SSL.

Follow steps below and generate SSL for 3650 days (ten long years)

## Regenerate SSL certificate and deploy as given below

su - zimbra -c 'zmcontrol stop'
rm -rf /opt/zimbra/ssl/*
rm -rf /opt/zimbra/ssl/.rnd
/opt/zimbra/java/bin/keytool -delete -alias my_ca -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit
/opt/zimbra/java/bin/keytool -delete -alias jetty -keystore /opt/zimbra/mailboxd/etc/keystore -storepass `su - zimbra -c 'zmlocalconfig -s -m nokey mailboxd_keystore_password'`
vi /opt/zimbra/bin/zmcertmgr


# Find line
# SUBJECT="/C=US/ST=N\/A/L=N\/A/O=Zimbra Collaboration Suite/OU=Zimbra Collaboration Suite/CN=${zimbra_server_hostname}"
# and change to your company name - may not be required if host name and is properply configured in etc/hosts

# then find and change you want value days expire cert validation_days=365 to validation_days=3650
# save /opt/zimbra/bin/zmcertmgr

/opt/zimbra/bin/zmcertmgr createca -new
/opt/zimbra/bin/zmcertmgr deployca -localonly
/opt/zimbra/bin/zmcertmgr createcrt self -new
/opt/zimbra/bin/zmcertmgr deploycrt self

su - zimbra -c 'zmcontrol start'

/opt/zimbra/bin/zmcertmgr deploycrt self
/opt/zimbra/bin/zmcertmgr deployca

su - zimbra -c 'zmupdateauthkeys'
/opt/zimbra/bin/zmcertmgr viewdeployedcrt