Skip to content

qmail spamfilter.8

Manvendra Bhangui edited this page Dec 13, 2024 · 8 revisions

NAME

qmail-spamfilter - spam filter for indimail

SYNOPSIS

qmail-spamfilter [ qqf] arg1] [arg2] ... ]

DESCRIPTION

qmail-spamfilter(1) allows indimail to execute antispam filter. It gets invoked by indimail programs using qmail-queue frontend when the QMAILQUEUE environment is set to qmail-spamfilter or when passed as a command line argument having qmail-spamfilter like below (which will have the message pass through qmail-dkim and qmail-spamfilter).

QMAILQUEUE="/usr/sbin/qmail-dkim /usr/sbin/qmail-spamfilter"

qmail-spamfilter also calls qscanq(8) to perform virus scanning or bad attachment scan if VIRUSCHECK environment variable is set to a value between 2 and 7.

qmail-spamfilter uses SPAMFILTER environment variable to execute the actual spam filter. The SPAMFILTER env variable can contain command line arguments. The spam filter defined by SPAMFILTER environment variable should read descriptor 0 and write to descriptor 1. Antispam filter is bypassed when SPAMFILTER is not set or if RELAYCLIENT and RELAYCLIENT_NOSPAMFILTER is set.

The sequence in which the filter program is run is given below

1. create a pipe and fork
2. dup write end of the pipe to descriptor 1 in the child and exec the
filter program

3. dup read end of the pipe to descriptor 0 in parent and exec
qmail-queue.

This gives the ability for the SPAMFILTER program to read the mail message
from descriptor 0 before passing it to qmail-queue through the pipe.

qmail-spamfilter will attempt to make the descriptor 0 seekable. This may be necessary for certain filter programs like bogofilter which allocate memory for the mail message when lseek(2) fails..

qmail-spamfilter by default, interprets the exit status of spam filter program as below

Exit Status Interpretation ----------- -------------- 0,1,2 Program ran successfully. Interpretation depends on filter implementation. HAMEXITCODE/SPAMEXITCODE can be set to decide what exit code should be treated as SPAM or HAM. For SPAM mails, mail will be accepted unless REJECTSPAM is set. See description below. 100 Mail will be bounced anything else Mail will be rejected with a temporary error

A typical application of this would be to run spam filtering software like spamassasin, bogofilter, etc

When the exit code of the filter program matches the value of SPAMEXITCODE, the mail is considered to be spam. When the exit code of the filter program matches the value of HAMEXITCODE, the mail is not consided to be spam. If the exit code of the filter program matches the value of UNSUREEXITCODE, the classication of mail as spam or ham couldn't be determined accurately. All other errors should be consided as temporary errors except for 100, which should be interpreted as a permanent error.

If REJECTSPAM is set to 1, the mail will be bounced back to the sender. mail can be redirected to the recipient specified in the globalspamredirect control file. The email id in globalspamdirect can be overridden by the environment variable GLOBALSPAMREDIRECT. If REJECTSPAM is set and globalspamdirect control file exists, spam mails will be bounced back to the sender as wll a copy redirected to the recipient specified in by globalspamredirect control file. You may decide not to generate a bounce to the sender by setting the environment variable REJECTSPAM to a value greater than 1 (i.e. black hole SPAM mails).

qmail-spamfilter invokes qmail-queue to deposit the mail. This can be changed by setting environment variable SPAMQUEUE or QUEUEPROG to the path of any qmail-queue frontend. It can also be changed by passing the path of any qmail-queue frontend (along with arguments to the qmail-queue frontend) on the command line. Passing command line arguments takes precedence over environment variable.

qmail-spamfilter sets an alarm of 86400 seconds to quit if it doesn't complete. This can be changed by setting DEATH environment variable. See the man pages for qmail-queue(8) and indimail-mta-internals(7) for more details.

EXIT CODES

qmail-spamfilter does not print diagnostics. It uses the following exit codes indicating the problem.

It exits 51 if it cannot allocate memory
It exits 55 if it is not able get the free space for the queue filesystem.
It exits 53 if the free space is below MIN_FREE value.
It exits 60 if it cannot create pipes or dup file descriptors.
It exits 61 if cannot change directory to QMAILHOME
It exits 68 if it cannot create temporary files to make the input seekable.
It exits 75 if cannot exec qscanq.
It exits 120 if it is not able to exec qmail-multi.
It exits 123 if qmail-multi crashes.

SEE ALSO

addresses(5), rfc-822(5) qmail-send(8), qmail-inject(8), qmail-smtpd(8), sendmail(8) indimail-control(5), qmail-header(5), qmail-queue(8), qmail-qmqpc(8), qscanq(8), cleanq(8), bogofilter(1), queue-fix(8), spawn-filter(8), indimail-mta-internals(7),

AUTHORS "Manvendra Bhangui" <manvendra@indimail.org>.

Clone this wiki locally