Virtual Users And Domains With Postfix, Courier And MySQL (Fedora Core 5) - Page 4

11 Install Razor, Pyzor And DCC And Configure SpamAssassin

Razor, Pyzor and DCC are spamfilters that use a collaborative filtering network. To install Razor and Pyzor, run

yum install perl-Razor-Agent pyzor

Then initialize both services:

chmod -R a+rX /usr/share/doc/pyzor-0.4.0 /usr/bin/pyzor /usr/bin/pyzord
chmod -R a+rX /usr/lib/python2.4/site-packages/pyzor
su -m amavis -c 'pyzor --homedir /var/spool/amavisd discover'
su -m amavis -c 'razor-admin -home=/var/spool/amavisd -create'
su -m amavis -c 'razor-admin -home=/var/spool/amavisd -register'

(You might have to run the last command twice if the first attempt fails.)

Then we install DCC as follows:

cd /tmp
tar xzvf dcc-dccproc.tar.Z
cd dcc-dccproc-1.3.42
./configure --with-uid=amavis
make install
chown -R amavis:amavis /var/dcc
ln -s /var/dcc/libexec/dccifd /usr/local/bin/dccifd

Now we have to tell SpamAssassin to use these three programs. Edit /etc/mail/spamassassin/ so that it looks like this:

vi /etc/mail/spamassassin/

# These values can be overridden by editing ~/.spamassassin/
# (see spamassassin(1) for details)

# These should be safe assumptions and allow for simple visual sifting
# without risking lost emails.

#required_hits 5
#report_safe 0
#rewrite_header Subject [SPAM]

# dcc
use_dcc 1
dcc_path /usr/local/bin/dccproc
dcc_add_header 1
dcc_dccifd_path /usr/local/bin/dccifd

use_pyzor 1
pyzor_path /usr/bin/pyzor
pyzor_add_header 1

use_razor2 1
razor_config /var/spool/amavisd/razor-agent.conf

use_bayes 1
use_bayes_rules 1
bayes_auto_learn 1


/etc/init.d/amavisd restart


Now I want to insert some custom rulesets that can be found on the internet into SpamAssassin. I have tested those rulesets, and they make spam filtering a lot more effective. Create the file /usr/local/sbin/

vi /usr/local/sbin/


cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

cd /etc/mail/spamassassin/ &> /dev/null && /usr/bin/wget -O &> /dev/null

/etc/init.d/amavis restart &> /dev/null

exit 0

Make the script executable:

chmod 755 /usr/local/sbin/

Then run that script once, it will fetch those rulesets and insert them into SpamAssassin:


We create a cron job so that those rulesets will be updated regularly. Run

crontab -e

to open the cron job editor. Create following cron job:

23 4 */2 * * /usr/local/sbin/ &> /dev/null

This will update the rulesets every second day at 4.23h.


12 Quota Exceedance Notifications

If you want to get notifications about all the email accounts that are over quota, then do this:

cd /usr/local/sbin/
mv quota.txt quota_notify
chmod 755 quota_notify

Open /usr/local/sbin/quota_notify and edit the variables at the top:

vi /usr/local/sbin/quota_notify

my $POSTFIX_CF = "/etc/postfix/";
my $MAILPROG = "/usr/sbin/sendmail -t";
my @POSTMASTERS = ('postmaster@isp.tld');
my $CONAME = 'ISP.tld';
my $COADDR = 'postmaster@isp.tld';
my $SUADDR = 'postmaster@isp.tld';
my $MAIL_REPORT = 1;


crontab -e

to create a cron job for that script:

0 0 * * * /usr/local/sbin/quota_notify &> /dev/null
Share this page:

10 Comment(s)

Add comment


From: trcodera at: 2006-10-06 08:02:34

ive been configuring fedora for almost two week already, i did all the things asked at perfect setup for fc5. im in the stage where i'm asked to set password for mysqladmin, but is says, access denied for user root@localhost, and i'm pretty sure i did something wrong and now i'm completely lost.. help..... i'm also planning of reinstalling fedora and go over all the process again.

From: at: 2006-11-16 23:34:22

Just a quick note to say thanks to both Falko Timme for the tutorial and bsquare for the 'addition instructions', some of which I needed, some I didn't.

All in all, great work.

From: at: 2006-11-16 23:47:35

Looking back over my notes, I did forget to mention that I did have some trouble getting amavis to run, giving errors about in syslog when issuing a /etc/init.d/amavisd start.

To get around this problem I did the following (from memory):-
yum remove perl-Net-DNS

..... which removes the following dependencies....

Then do :-
perl -MCPAN -e shell
install Net::DNS
install Mail::SPF::Query
>>> Y to dependencies 'Sys::Hostname::Long'
install Mail::SpamAssassin::Plugin::Razor2

Then reinstall :-
yum install perl-Mail-SPF-Query
yum install perl-Razor-Agent
yum install spamassassin
yum install amavisd-new

From: trcodera at: 2006-10-06 08:09:03


From: bsquare at: 2006-10-07 23:15:02

Before all, after having read several tutorials, I can say this one is very interesting.

Anyway, I would like to add some potentially needed instructions (it was the case for me).

 * the cyrus-sasl-plain package must be installed too, to avoid SASL Authentication error from postfix,

 * check if the "loadplugin Mail::SpamAssassin::Plugin" instruction are uncomment for DCC, Razor and Pyzor into *.pre files usually under /etc/mail/spamassassin directory,

 * dcc_add_header and  pyzor_add_header are deprecated (Cf., instead use respectively add_header all DCC _DCCB_: _DCCR_ and add_header all Pyzor _PYZOR_,

Anyway, amavisd remove a great part of the header created by spamassassin and so won't be shown into "final" mail (but it will be shown using spamassassin directly like command "spamassassin - t /path/of/mail").

 * to make amavis keep a part of the spamassassin header, add the following lines to your amavisd.conf :

$remove_existing_spam_headers = 0;

$sa_spam_report_header = 1;

 * For dccifd to work, DCCIFD_ENABLE must be set to 1 into the dcc_conf file (under /var/dcc directory in this tutorial), and the good path of the socket is /var/dcc/dccifd specified by the option dcc_dccifd_path (defined into the spamassassin file),

 * a link can be made from /var/dcc/libexec/rcDCC to /etc/init.d/dcc to "define" the dcc service (use then 'chkconfig --add dcc' for it to be automatically launched at startup),

 * it can be needed, to be sure that path are respected, to add the following lines to the file :

dcc_home /var/dcc/

razor_config /var/spool/amavisd/.razor/razor-agent.conf

bayes_path /var/spool/amavisd/.spamassassin/bayes

* for the spamassassin bayes system to be used, it is needed to make it learn with a mail corpus (with mbox format), one with at least 200 spams, and the other 200 hams. For instance, this format is used by Thunderbird. It is easy to create a mbox (a simple folder under Thunderbird) for each kind of mails and then call the sa-learn tool on each mbox, for instance :

/usr/bin/sa-learn -C /var/spool/amavisd/.spamassassin --showdots --ham --mbox /path/mbox/with/only/ham

/usr/bin/sa-learn -C /var/spool/amavisd/.spamassassin --showdots --spam --mbox /path/mbox/with/only/spam

It seems that the optimal number of each mails, for the best learning, is 1000 for each.

It is very important that the number of ham is upper than the one of spam. 

 * the use of the sa-update tool should be defined automatically under cron like

  - to begin, be sure that gnupg is installed, else use the command yum install gnupg,

  - import the spamassassin GPG Key :

cd /etc/mail/spamassassin
gpg --import GPG-SIGNING-KEY

  - sa-update --updatedir /usr/share/spamassassin      (can be used into cron table)


 * in any case, to check if personal rules and updated rules are valid, use the spamassassin --lint command  


There is still some little problems whose solution remain to be found :

 * why when starting clamd.amavis there is always a warning about a at least 7 days old database, although freshclam is frequently launched without any problem,

 * why sometimes the DCC header tags are not replaced by corresponding information (when DCC check failed with X-DCC complain).


As soon as I find answer, I will report them there.

Hoping this additional instructions will help.

Best regards. 


From: at: 2006-11-05 21:57:12

Just a small note, db4-devel is needed by postfix-2.2.8-1.2.i386

# rpmbuild -ba postfix.spec
error: Failed build dependencies:
        db4-devel is needed by postfix-2.2.8-1.2.i386

To fix yum db4-devel

# yum install db4-devel

From: at: 2007-10-24 20:45:33

I've been running a mail server built using this HOWTO for a while now.  I recently updated the entire server with a "yum update".  Email clients could no longer connect to the server via POP3 or IMAP if SSL was enabled.  I was getting errors like this in the error log: 

Oct 23 13:19:32 mailhost pop3d-ssl: couriertls: connect: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
Oct 24 10:36:13 mailhost imapd-ssl: couriertls: connect: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

I was able to fix this by editing the following files:


 I changed the TLS_PROTOCOL setting from SSL3 to SSL23 in both of these files:


Then, I restarted courier-authlib and courier-imap and things were working again:

 service courier-authlib restart
 service courier-imap restart

The following commands were helpful in testing things out:

openssl s_client -connect mailhost:993 -state -debug
openssl s_client -connect mailhost:995 -state -debug
openssl s_client -ssl2 -connect mailhost:993 -state -debug
openssl s_client -ssl3 -connect mailhost:993 -state -debug
openssl s_client -ssl2 -connect mailhost:995 -state -debug
openssl s_client -ssl3 -connect mailhost:995 -state -debug

I hope this helps someone else, as I spent way too much time trying to solve it.


From: at: 2007-10-25 19:54:42

One more thing to add to my last comment:

After the update, I also cannot send email.  The error logs show this:

 Oct 25 11:55:19 mailhost postfix/smtpd[10671]: warning: SASL authentication failure: cannot connect to Courier authdaemond: Permission denied
Oct 25 11:55:19 mailhost postfix/smtpd[10671]: warning: unknown[xx.xx.xx.xx]: SASL LOGIN authentication failed: generic failure

With a quick google I found a solution:

chmod o+x /var/spool/authdaemon

That solved it for me! 

From: tommytomato at: 2006-10-03 12:33:24

This gave me alot errors, alot of dead links and packages could not be installed, it allso took along time to complete.

 shame i've allways liked Fedore Core


From: djtremors at: 2006-10-27 05:43:10

I would more likely follow the virtual howtos listed from the postfix website

 which i followed and successfully made my own server and my own GUI mods for postfixadmin (