← Back to Blog

Configuring SpamAssassin on DirectAdmin

Introduction

A customer of ours had been complaining about receiving too much spam and asked us to take a look. He's a gas engineer, and his website is advertising his services. The site is running on one of our offshore VPS hosting plans with DirectAdmin. As we absolutely love this control panel, we had no problem taking a look.

However, taking a look is one thing. Actually getting the spam filter working is another. We followed the instructions set out by the DirectAdmin staff, but encountered several errors along the way. This tutorial documents our troubleshooting process and the solution we found.

The Problem: Missing Perl Modules

When we attempted to configure SpamAssassin on DirectAdmin, we encountered the following error during the dependency check:

dependency check complete...

REQUIRED module missing: HTML::Parser
REQUIRED module missing: Net::DNS
REQUIRED module missing: NetAddr::IP
REQUIRED module missing: Time::HiRes
REQUIRED module missing: Archive::Tar
REQUIRED module missing: IO::Zlib

So, we were missing several Perl modules required for SpamAssassin to function properly. Let's install them.

Solution 1: Installing Perl Modules via CPAN

Our first attempt was to install the required modules using CPAN (Comprehensive Perl Archive Network):

cpan -i Archive::Tar Digest::SHA Mail::SPF IP::Country Net::Ident IO::Socket::INET6 Compress::Zlib Mail::DKIM LWP::UserAgent HTTP::Date Encode::Detect ExtUtils::MakeMaker

While this would normally work, it didn't this time, and we got the following error:

Catching error: "Can't locate object method "data" via package "CPAN::Modulelist" (perhaps you forgot to load "CPAN::Modulelist"?) at (eval 28) line 1.
at /usr/share/perl5/CPAN/Index.pm line 518
CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl5/CPAN/Index.pm line 85
CPAN::Index::reload('CPAN::Index', 1) called at /usr/share/perl5/CPAN/Index.pm line 15
CPAN::Index::force_reload('CPAN::Index') called at /usr/share/perl5/CPAN/Shell.pm line 561
CPAN::Shell::reload('CPAN::Shell', 'index') called at /usr/share/perl5/CPAN.pm line 375
eval {...} called at /usr/share/perl5/CPAN.pm line 372
CPAN::shell() called at /usr/bin/cpan line 198" at /usr/share/perl5/CPAN.pm line 391
        CPAN::shell() called at /usr/bin/cpan line 198

Solution 2: Using YUM Package Manager

Since CPAN wasn't working, we decided to use YUM (Yellowdog Updater Modified) instead. We're running CentOS 6 64-bit on this VPS, so YUM is the native package manager.

Let's install the required Perl modules using YUM:

yum install perl-HTML-Parser perl-Net-DNS perl-NetAddr-IP perl-Time-HiRes perl-Archive-Tar perl-IO-Zlib

This command installs the following Perl modules:

  • perl-HTML-Parser - Provides HTML::Parser module
  • perl-Net-DNS - Provides Net::DNS module
  • perl-NetAddr-IP - Provides NetAddr::IP module
  • perl-Time-HiRes - Provides Time::HiRes module
  • perl-Archive-Tar - Provides Archive::Tar module
  • perl-IO-Zlib - Provides IO::Zlib module

Additional Error: Missing HTTP::Date Module

After installing the modules above, we tried to compile SpamAssassin again, but encountered another error:

Can't locate HTTP/Date.pm in @INC (@INC contains: /usr/share/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5) at /usr/bin/sa-update line 91.
BEGIN failed--compilation aborted at /usr/bin/sa-update line 91.

This error indicates that the HTTP::Date module is missing. This module is part of the libwww-perl package.

Final Solution: Installing libwww-perl

To fix this issue, we installed the perl-libwww-perl package:

yum -y install perl-libwww-perl.noarch

The -y flag automatically answers "yes" to all prompts, making the installation non-interactive. The .noarch indicates this is a no-architecture package that works on all system architectures.

Compiling SpamAssassin

After installing all the required dependencies, we were finally able to compile SpamAssassin successfully:

./build spamassassin

Voila! SpamAssassin is now installed and running on the DirectAdmin server!

Summary of Commands

Here's a quick reference of all the commands used to configure SpamAssassin on DirectAdmin:

  1. Install required Perl modules:
    yum install perl-HTML-Parser perl-Net-DNS perl-NetAddr-IP perl-Time-HiRes perl-Archive-Tar perl-IO-Zlib
  2. Install libwww-perl package:
    yum -y install perl-libwww-perl.noarch
  3. Compile SpamAssassin:
    ./build spamassassin

System Requirements

This tutorial was tested on:

  • Operating System: CentOS 6 64-bit
  • Control Panel: DirectAdmin
  • Package Manager: YUM

If you're running a different Linux distribution (such as Ubuntu or Debian), you'll need to use the appropriate package manager (apt-get for Debian/Ubuntu) and the corresponding package names.

Why This Solution Works

Using YUM instead of CPAN has several advantages:

  • Faster installation: YUM installs pre-compiled packages, which is much faster than compiling from source
  • Better dependency management: YUM automatically resolves and installs dependencies
  • System integration: Packages installed via YUM are better integrated with the system
  • Easier updates: System updates will also update these packages automatically

Conclusion

Configuring SpamAssassin on DirectAdmin can be tricky when CPAN isn't working properly. By using YUM to install the required Perl modules instead, we were able to successfully install and configure SpamAssassin for our customer's spam filtering needs.

This solution is particularly useful for CentOS/RHEL systems where YUM is the native package manager. The key is to identify the missing dependencies and install them using the system's package manager rather than relying solely on CPAN.