foad
Section: (1)
Updated: 13 Jan 2001
Index
Return to Main Contents
NAME
foad - f* off and die spam
SYNOPSIS
foad
[-bhntv]
[-c .foadrc]
DESCRIPTION
foad
reads anchored case-insensitive extended regular expressions, which may
be anchored, from
$HOME/.foadrc
representing/matching the users valid e-mail addresses and mailing lists and
reads an e-mail message's headers from stdin via
procmail(1),
extracts the
From:, To:, Cc:, Bcc: and their Resent-*: counter-parts. These headers
are split and trimmed down to just the addresses. For example, "joe shmoe"
<joe@foo.com> is reduced to joe@foo.com and mail lists such as
'mail-list-foo: ;' to mail-list-foo:. Then the regexes are applied to each of
the addresses reduced from the headers until there is a match or there are no
more comparisons to be made.
These functions could be done with
procmail(1)
with multiple recipes, but this method uses one recipes and is IMO easier to
manage.
OPTIONS
- -b
-
Also egrep Bcc: and Resent-Bcc: headers. These headers are only seen
in mail originating on the delivery host and even then only with some
MTAs.
- -c .foadrc
-
Specify an alternate run-config file. The default is
$HOME/.foadrc.
- -f
-
Also egrep From: and Resent-From: headers.
- -h
-
Print usage info and return exit code 1.
- -n
-
Negate the exit code. This applies to all exit codes here, but with the
stipulation that when parsing command-line arguments,
foad
may exit before the negate option is parsed and therefore the exit code would
not be negated.
- -t
-
Read
$HOME/.foadrc
and return exit code 1 (0, if negate option is supplied) on error. This tests
reading the configuration file and compiling the regexes.
- -v
-
Print version tag and exit.
SAMPLE RUN-CONFIG
$HOME/.foadrc
may contain, one per-line, comments beginning with ^# and anchored or
un-anchored case-insensitive extended regular expressions. See
egrep(1)
for specifics on extended regex formats, etc.
# comment
# match joe@domain.net or joe@something.domain.net
joe@([^[:space:]]+.)?domain.net
# match joe@domain.net, exactly
^joe@domain.net$
# mail lists
# match nanog@merit.edu or nanog-something@merit.edu
nanog(-[^[:space:]]+)?@merit.edu
# <EOF>
PROCMAIL RECIPES
foad
is intended to be run via
procmail(1).
Below are two sample
procmailrc(5)
recipes. One of these should be added as the last recipe in your
.procmailrc,
or second to last if you have a default recipe.
# this recipe will save headers of filtered messages
# (when foad exits with exit code 0, aka. no matches)
# to the file $MAILDIR/spam
#
:0 W h:
* ? /usr/local/bin/foad
$MAILDIR/spam
# this recipe will save the entire filtered messages
# (when foad exits with exit code 0, aka. no matches)
# to the file $MAILDIR/spam
#
:0 W:
* ? /usr/local/bin/foad
$MAILDIR/spam
The destination for filtered mail ($MAILDIR/spam) could be /dev/null to
dump the spam altogether. However, it is important to note that there is
no way to (reliably) match valid email that was blind carbon copied (bcc)
to the recipient, because the bcc: header will not be included at final
delivery in most cases. Senders that send valid bcc'd email can either
be matched in the recipients
.procmailrc
or add to the
.foadrc
and invoke foad with the
-f
option.
There is also an issue when senders use a MUA that hides recipient addresses
behind a mail list tag such as 'mail-list-foo: ;'. The problem here is that
the tag is free-form. So, while these are reduced as mentioned above, it can
change at the whim of the user and there can be as many different tags as
there are users. These could be matched with the regex ^[^ ]+:$, but this
method is often used by spammers. Personally, i choose to match known
tags, such as that for the IETF secretariat and filter the rest, which are
usually garbage anyway.
EXIT STATUS
If a successful match is made,
foad
returns exit code 1, else 0.
The exit code will also be 1 if an invalid command line option is specified,
an error occurs while reading the rc file (
.foadrc
), parsing the mail headers, or while compiling and or executing the regexes.
This means that a run-time error will be treated like a match, from procmail's
perspective, and filtering will not occur.
FILES
- $HOME/.foadrc
-
Default run-config file.
SEE ALSO
egrep(1),
procmail(1),
procmailrc(5)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- SAMPLE RUN-CONFIG
-
- PROCMAIL RECIPES
-
- EXIT STATUS
-
- FILES
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 16:44:16 GMT, February 10, 2023