Copyright 1994, 1995, 1996, 1999, 2000, 2001 Free Software Foundation,
Inc.

Before installing make sure you have already downloaded, compiled and
installed the clamav package. Clamdmail calls the clamd daemon, so it
has to be running for clamdmail to work!!


First of all you should make sure you have copied the clamdmail tar ball
to the source directory of Clamav.

1. cd /usr/local/src/clamav-0.65

2. tar zxvf clamdmail.tar.gz


Now you can either:

- Run ./install. This will set up ripmime and do a configure, make and
  make install.

or do what './install' tries to do for you:

3. cd clamdmail-0.15

4. cd ripmime-1.3.0.5

5. make libripmime

6. cp libripmime.a /usr/local/lib/

7. /sbin/ldconfig

8. ./configure

9. make

10. make install


Before setting up clamdmail for your MTA you should try testing it on
the command line. You can use the 'testmail' file in this directory as
follows:

	clamdmail --admin=postmaster@yourdomain.com < testmail|more

You should get a warning mail on stdout. Try a few of the different
arguments to get a feel for how they work.

---------------------------------------------------------------------

IMPORTANT NOTE 
--------------

Clamdmail REQUIRES you use the --admin argument. If you don't supply
an --admin argument it will just tell you to give it one (wink wink)
and do nothing. To conclude, ALWAYS supply an --admin argument.

Type 'clamdmail -h' for usage.        

---------------------------------------------------------------------



Integrating clamdmail with SpamAssassin
---------------------------------------

Install the spamc/spamd combination available in the SpamAssassin package.

Make sure spamd is up and running.

You can now use the '--spam' option when running clamdmail to check messages 
for spam before they are scanned for viruseseseses.


Setting up with QMail
---------------------


1. You need to make sure that you have applied Bruce Guenter's QMail patch. It's 
   included here in the qmail directory.

2. Also in the QMailPatch directory is the source file qmail-call.c This is a 
   modified version of qmail-spamc.c by jpeacock@rowman.com included in the Spamassassin 
   distribution. This contains the call to clamdmail.
   Make sure the call to clamdmail contains the parameters you want. Here is an example 
   of the call you would use for calling SpamAssassin and extracting messages encapsulated
   with TNEF:

	execlp("clamdmail", "clamdmail", "--spam", "--quar=/usr/local/share/quar", "--admin=postmaster@you.you", NULL);

   Note that the default quar directory may not work for you. Whatever the quar directory is make sure
   it is owned by the clamav user and group.

   If your qmail-inject is not in /var/qmail/bin  and you are using the --quar argument you will need to specify
   the location of qmail-inject on the command line as well. e.g.:

	execlp("clamdmail", "clamdmail", "--spam", "--quar=/usr/local/share/quar", "--mta=/your/funny/location/qmail-inject", "--admin=postmaster@you.you", NULL);

   Now compile qmail-call.c as follows:

	gcc -o /usr/bin/qmail-call qmail-call.c

3. Make sure you have copied /var/qmail/bin/qmail-queue to /usr/bin/ and run the following command:

	chown qmailq:qmail /usr/bin/qmail-queue

   Or you can simply do: ln -s /var/qmail/bin/qmail-queue /usr/bin/qmail-queue

4. If you're using daemontools, you can skip 5, and 6 below and just do the following:

	- Add QMAILQUEUE="/usr/bin/qmail-call"; export QMAILQUEUE in /service/qmail-smtpd/run.
	- Then run: svc -t /service/qmail-smtpd.

5. Make sure you have  added a line to /etc/profile as follows:
	export QMAILQUEUE="/usr/bin/qmail-call"


6. You will need to reboot before the QMAILQUEUE variable can take effect (maybe there's a better way
   of doing this, but I don't know it)


7. It should work now. Every time qmail processes a message, it will pass it to clamdmail on stdout, if
   the --spam flag is set on clamdmail it will get passed to spamd before being scanned for viruses by 
   clamd. Clamdmail will then spit it out on stdout and qmail will deliver it.


Setting up with other MTAS
--------------------------

As long as you can get your MTA to pass clamdmail mail messages on stdin and receive them back from clamdmail's stdout
then you can use clamdmail for processing your mail.

If you are using the --quar option with your MTA, you will need to specify the location of your mailer's equivalent of
qmail-inject (i.e. the binary that allows you inject messages for delivery) using the --mta flag. 


Thanks to Benjamin Tomhave <btomhave@sofast.net> for the daemontools setup method.
Thanks to Bastiaan Van der Put for help in testing.


Setting up with Kmail
---------------------

This will catch any virus mail and provide you with a warning message with the mail attached. 

MAKE SURE YOU HAVE CLAMD RUNNING AS A DAEMON!!

The filter setup is the work of five minutes (if that!) if you have a working spamassassin and clamdmail set up:
 
The Filter Criteria in question is "<size> <is less than> 250000" (that's about 450 kB).
 
The Filter Action is "<pipe through> clamdmail --admin=your@email.address"  or you can check for spam at the same time by using:
"<pipe through> clamdmail --admin=your@email.address --spam"
	NOTE: You will need to have the spamc/spamd flavour of spamassassing up and running for this to work.
 
Then, in the Advanced Options, uncheck the "If this filter matches, stop processing here" box. 
If you keep this filter at the top, it will analyze all incoming mail, decide whether it's a virus or not, and flag it accordingly.
 
I've got a second filter behind it, which looks for "X-Spam-Flag equals YES" and diverts them into a specific folder called "Probably Spam".
 
