DIYMacServer » DSPAM

5 posts

Regexp instead of PCRE in postfix access?

started at 26 Jan 2007
started by grgcombs
last reply from richard5
  • grgcombs
    26 Jan 2007
    #

    So I think I've found some sample regular expression code that *might* work in getting dspam running with postfix without PCRE... Granted I'm not sure what's happening, but I think this will break out spam-person@whoever.com, ham-person@whoever.com, and person@whoever.com ... and send them off to different parts of postfix to do handle training for dspam....

    /^spam-(.*)/ FILTER dspam-add:${1}
    /^ham-(.*)/ FILTER dspam-del:${1}
    /(.*)/ FILTER dspam:${1}

    I'm not sure if the last one is necessary...

    And then here's what goes in master.cf:

    dspam-add unix - n n - - pipe
    flags=Rhq user=dspam argv=/usr/bin/dspam --user ${user}@${nexthop} --class=spam --source=error
    dspam-del unix - n n - - pipe
    flags=Rhq user=dspam argv=/usr/bin/dspam --user ${user}@${nexthop} --class=innocent --source=error

    Now I'm not sure if this regexp needs to go in transport_maps, or access, or what...

    Anyone do anything like this yet?
  • 26 Jan 2007
    #

    where did you put the FILTER stuff in in main.cf. If you put it in the same section as the documented filter stuff than it won't work as that filter is only hit by mail coming from the outside world and not for authenticated users !

    You should put the retrain stuff in transport maps !
  • grgcombs
    26 Jan 2007
    #

    I figured it out ... I went back and redid things since I last posted to be more like yours

    in main.cf I added:

    check_client_access regexp:/etc/postfix/dspam_regexp

    instead of the "pcre:" business...

    at the bottom I put:
    dspam_destination_recipient_limit =1
    dspam-add_destination_recipient_limit = 1
    dspam-del_destination_recipient_limit = 1

    and then this went in my dspam_regexp file:
    /^spam-(.*)/ FILTER dspam-add:${1}
    /^ham-(.*)/ FILTER dspam-del:${1}
    /^(.*)/ FILTER dspam:${1}

    This way it's more like yours, but I don't have to worry about a retraining script, since I can just use these other transport methods for training.

    The other part of my problem is that since I'm doing my own parsing of the user names, I had to turn off the parsing in the dspam.conf file.

    g
  • grgcombs
    26 Jan 2007
    #

    Oh ... I think I see what you're saying. my users won't be able to use those transports at all will they ..... can you show me how to setup the retraining as tranport maps instead?

    g
  • 27 Jan 2007
    #

    The thing is that you are mixing up two seperate functions into one.

    The listing of the PCRE filter

    /./     FILTER dspam:dspam

    in the option "smtpd_recipient_restrictions". Is only there to filter incoming mail only. If you leave out this option all outgoing mail will be filtered as well which is not something you would want.

    The retraining transports are there for another reason, you want to feed dspam with incorrect identified emails and you don't want it delivered to a users mailbox. Therefore you define a separate transport.

    In main.cf you add the following lines to do that

    recipient_delimiter = -

    (to separate the username from the -spam in the mail address)

    and

    transport_maps = hash:/etc/postfix/transport
    local_recipient_maps = proxy:unix:passwd.byname $alias_maps $transport_maps


    to define the transports:

    and then you ceate a file called transport and add:

    spam@mydomain.tld    dspam-retrain:spam
    ham@mydomain.tld     dspam-retrain:innocent
    notspam@mydomain.tld     dspam-retrain:innocent



    do a

    sudo postmap transport

    to convert it.

    and add

    dspam-retrain   unix    -       n       n       -       10      pipe
      flags=Ru user=dspam argv=/usr/local/bin/dspam-retrain $nexthop $sender $recipient


    as a transport in our master.cf for retraining purposes !

    The retraining shell script you can download from here.

    Hope this helps !

Reply

You must log in to post.