The most common cause of this error is a problem with the ClamAV installation. First check to make sure it's running by running the following:


# svstat /clamd

and you should get an output similar to


/service/clamav/: up (pid 32616) 1972 seconds

The user above can be anything. I personally use user qscand to run clamav as well as SpamAssassin.

Check the freshclam logs at /var/log/qmail/clamd/current and check for errors. If you see any It could be due to the ownership/permissions on /var/db/clamav.

Most of these issues can be resolved by cleaning out the entire clamav installation. I would remove the following folders/files and then doing a clean install of clamav. Please also note that if you do not have these types of paths/files on your system, they may vary from distro to distro:

Files:
/usr/local/etc/rc.d/clamav-clamd (could also be startup scripts in /etc/rc.d or /etc/init.d in other systems)
/usr/local/etc/rc.d/clamav-freshclam (could also be startup scripts in /etc/rc.d or /etc/init.d in other systems)

Folders:
/usr/local/share/doc/clamav
/var/db/clamav
/var/log/clamav
/var/mail/clamav
/var/run/clamav

References:
For FreeBSD users, remove all the clamav references from /etc/rc.conf
Take freshclam out of crontab This may not exist if you are running clamav from daemontools.


# cd /var/qmail/bin

# chmod 4755 qmail-scanner-queue
# chown qscand:qscand qmail-scanner-queue

# vi qmail-scanner-queue.pl

The first thing you will want to troubleshoot when getting this error is to find out if this is a qmail related problem or a qmail-scanner issue. In most cases, it's either qmail-scanner, clamav or spamassassin causing the problem.

Go to /var/qmail/supervise/qmail-smtpd/run and comment out the following line so it looks like this:


#QMAILQUEUE="$VQ/bin/qmail-scanner-queue"

Restart qmail and then try sending a test message. If it goes through, We can proceed with the next step. Skip the next paragraph and continue with the next.

If you don't get your test message, it is a qmail delivery problem. What you will want to run is qmailctl stat and make sure ALL SERVICES are up FOR MORE than one second. If something is running around 0-1 seconds consistently, Something is wrong with that service. Take a look at the logs for that service and troubleshoot from there.

Now we know that it's qmail-scanner related issue. Lets take a quick look at the QMAILQUEUE line in /var/qmail/supervise/qmail-smtpd/run:


QMAILQUEUE="$VQ/bin/qmail-scanner-queue"

The Major hint here is to make sure you used quotation marks ( " ) and not an Apostrophe ( ' )

We can also check spamassassin perl dependancies. Run the following command but change the version number in the Mail-SpamAssassin section:


# /usr/ports/mail/spamassassin/work/Mail-SpamAssassin-3.x.x/build/check_dependencies

It is very important that the Perl versions are the same. So if one perl module is 5.24.2 and the rest are 5.24.1, It would be in your best interest to update that perl module to 5.24.2 as well. .

Another thing we will check is to make spamd is running.

The way to check this is by running


# svstat /service/spamd

You should get the following output:


/service/spamd/: up (pid 2599) 2933 seconds

You can also check the log files at the following locations to look for a more descriptive error:

/var/log/maillog
/var/spool/qmailscan/qmail-queue.log
/var/log/qmail/qmail-smtpd/current

Also try chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl

See Disabling SpamAssassin or Clamav from qmail-scanner below:

Disabling SpamAssassin or Clamav from qmail-scanner

If you use the clamav ownership, rather than qscand, the perl wrapper ends up
owned as qscand, rather than clamav.

Also check out John Simpsons post about getting qmail-scanner to work with clamav.

https://qmail.jms1.net/clamav/qmail-scanner.shtml

Make sure that /var/spool/qmailscan/quarantine-attachments.db is being owned by qscand:qscand. Running /var/qmail/bin/qmail-scanner-queue.pl -g as root (w/o setuidgid) will change the db ownership