On Fri, Sep 12, 2014 at 10:12:38PM -0700, Den wrote:

> I was just wondering what exactly does the line below do? Could anybody
> comment / advise, please? It does not actually check and *confirm* that the
> code, syntax, etc. of any regexp present in /filter/ (example) is 100%
> correct does it?
> 
>  postmap -q "/^Subject:.*\*{5}SPAM\*{5}/"  regexp:/etc/postfix//filter/   

It means you're too tired to think straight. :-(

* You're using a regexp pattern instead of an input string to match.
* Your regexp table is a directory, and is not what's in main.cf.

A sensible version of this is:

    $ exec bash
    $ /usr/sbin/postmap -q "Subject: *****SPAM*****" regexp:<(
            echo '/^Subject:.*(\*{5}SPAM\*{5})/ MATCHED ${1}'
        )
    MATCHED *****SPAM*****

If you were to ensure that the file actually used in main.cf
$header_checks listed sensible content:

    main.cf:
        header_checks = regexp:${config_directory}/spamdiscard

    spamdiscard:
        # Flush left, with no leading whitespace on any lines:

        # All subject rules go here between "if" and "endif"
        if /^Subject:/
        /DISCARD WITH PREJUDICE/        DISCARD
        /(\*{5}SPAM\*{5})/              DISCARD ${1}
        # Any additional rules below
        # ...
        # /pattern/                     DISCARD optional text
        # ...
        # Finally log any subjects that don't hit any rules
        /^/                             WARN
        # Once tests are concluded comment out WARN above, and
        # short-circuit via DUNNO, since no other subjects will
        # be matched by any rules below for any other headers.
        /^/                             DUNNO
        endif

        # hypothetical
        if /^X-Some-Other-Header:/
        # /pattern/     ACTION
        # ...
        /^/     DUNNO
        endif

        # still hypothetical
        if /^X-Yet-Another-Header:/
        # /pattern/     ACTION
        # ...
        /^/     DUNNO
        endif

Then you'd be able to test, and either see discarded messages, or
see the actual subjects that did not match any rules.

-- 
        Viktor.

Reply via email to