LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Procmail - help w/ recipe to sort mailer-daemons (https://www.linuxquestions.org/questions/linux-software-2/procmail-help-w-recipe-to-sort-mailer-daemons-342516/)

Ratclaws 07-12-2005 12:51 PM

Procmail - help w/ recipe to sort mailer-daemons
 
First off: go easy, I'm a procmail newb

I've been playing with my .procmailrc for a few days now, but I just can't
seem to get my recipe working.
I almost had it at one point, but accidentally deleted my .procmailrc when
trying to clear out my procmail.log :)

Can anyone help out with this?? I know I got a lot of my ":0 *"'s screwed
up. I've been RTFM'ing for quite some time now, but im just stuck....

I'll just comment what im attempting in the below .procmailrc file.
~mailsort/.procmailrc
Code:

######### .procmailrc ################
SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/local/bin:/usr/sbin:
SENDMAIL=/usr/sbin/sendmail
VERBOSE=on
LOGFILE=$HOME/procmail.log
UMASK=077
LOCKTIMEOUT=1024
TIMEOUT=960
SUSPEND=16
LINEBUF=4096
NL="
"


#  Check to see if my Loop tag is in there. If it is, then I want to
mark
#  this message as a problem
#
:0 fhw:
* ^X-DR-Loop: TAGGED
* ^Subject:\/.*
    {
        LOG = "Caught a Loop $NL"
        |formail -I "Subject: PM-Rule DR-Loop-> $MATCH"
    }


# otherwise, add the TAG
:0 c:
*
    {
        LOG = "Adding at Loop tag"
        |formail -A "X-DR-Loop: TAGGED"
    }
#########################################################3



####################################
# Catch some auto responses messages
#
:0 fh w
* ^Auto-Submitted: auto-generated(failure)
* ^Subject:\/.*
    {
      LOG = "PM 1 was hit"
      |formail -I "Subject: PM-Rule 1 -> $MATCH"
    }

:0 fh w
* ^Content-Type: multipart/report; report-type=delivery-status;
* ^Subject:\/.*
    {
        LOG = "PM 2 was hit"
        |formail -I "Subject: PM-Rule 2 -> $MATCH"
    }

:0 fh w
* ^_MAILER
* ^Subject:\/.*
    {
        LOG = "PM 3 was hit"
        |formail -I "Subject: PM-Rule 3 -> $MATCH"
    }
######################################################





#####################################################
#  Collect any messages that are marked as a problem,
#  and send it to my address
#
:0
* ^Subject: PM-Rule*
    {
        LOG="Matched a PM Rule $NL"
        !catchall@example.com
    }



#######################################################3
#
#  Finally, any message that made it this far should be marked with
#  my loop and then resent to the same account.
#  ie. When i recieve the message, i want the subject to say:
#  PM-Rule  MY-Loop-> subject
#
:0:
*
    {
        !mailsort
    }
### Eventually this will be forwarding to someone elses address,
### but for now I want to see if any bounc messages
### make it past my filter.

And here is my ~mailsort/procmail.log
----- SNIP -----
Code:

######### procmail.log ###############
procmail: Assigning "UMASK=077"
procmail: Assigning "LOCKTIMEOUT=1024"
procmail: Assigning "TIMEOUT=960"
procmail: Assigning "SUSPEND=16"
procmail: Assigning "LINEBUF=4096"
procmail: No match on "^X-DR-Loop: TAGGED"
procmail: Extraneous filter-flag ignored
procmail: Extraneous locallockfile ignored
procmail: Extraneous deliver-head flag ignored
procmail: Skipped "|formail -I "Subject: PM-Rule DR-Loop-> $MATCH""
procmail: Match on ""
procmail: Locking ".lock"
procmail: Forking "procmail"
procmail: [6548] Tue Jul 12 14:19:29 2005
procmail: Assigning "LOG=Adding at Loop tag"
Adding at Loop tag
procmail: Skipped "|formail -A "X-DR-Loop: TAGGED""
procmail: No match on "^Auto-Submitted: auto-generated(failure)"
procmail: Extraneous filter-flag ignored
procmail: Extraneous deliver-head flag ignored


Ratclaws 07-12-2005 04:17 PM

SOLVED !
 
here is the new .procmailrc
Code:

SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/local/bin:/usr/sbin:
SENDMAIL=/usr/sbin/sendmail
VERBOSE=on
LOGFILE=$HOME/procmail.log
UMASK=077
LOCKTIMEOUT=1024
TIMEOUT=960
SUSPEND=16
LINEBUF=4096
NL="
"


#  Check to see if my Loop tag is in there. If it is, then I want to mark
#  this message as a problem
#
:0
* ^X-DR-Loop: TAGGED
* ^Subject:\/.*
    {
        LOG = "Caught a Loop $NL"
        :0 fhw
        |formail -I "Subject: PM-Rule DR-Loop-> $MATCH"
    }


# otherwise, add the TAG
:0
* !^X-DR-Loop: TAGGED
    {
        LOG = "Adding a Loop tag$NL"
        :0 fhw
        |formail -A "X-DR-Loop: TAGGED"
    }
#########################################################3



####################################
# Catch some auto responses messages
#
:0
* ^Auto-Submitted: auto-generated\(failure\)
* ^Subject:\/.*
    {
        LOG = "PM 1 was hit$NL"
        :0 fhw
        |formail -I "Subject: PM-Rule 1 -> $MATCH"
    }

:0
* ^Content-Type: multipart/report; report-type=delivery-status;
* ^Subject:\/.*
    {
        LOG = "PM 2 was hit$NL"
        :0 fhw
        |formail -I "Subject: PM-Rule 2 -> $MATCH"
    }

:0
* ^FROM_MAILER
* ^Subject:\/.*
    {
        LOG = "PM 3 was hit$NL"
        :0 fhw
        |formail -I "Subject: PM-Rule 3 -> $MATCH"
    }
######################################################





#####################################################
#  Collect any messages that are marked as a problem,
#  and send it to my address
#
:0
* ^Subject: PM-Rule*
    {
        LOG="Matched a PM Rule $NL"
        :0
        !catchall@example.com
    }



#######################################################3
#
#  Finally, any message that made it this far should be marked with
#  my loop and then resent to the same account.
#  ie. When i recieve the message, i want the subject to say:
#  PM-Rule  MY-Loop-> subject
#

:0
*
    {

        LOG = "Passed All Filters$NL"
        :0 fhw
        * ^Subject:\/.*
        |formail -I "Subject: PASSED Filter -> $MATCH"

        :0
        !catchall@example.com
    }



All times are GMT -5. The time now is 02:18 AM.