Procmail recipe issue... Please help!
Procmail recipe issue... Please help!
am 12.07.2005 18:32:16 von Janice
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....
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
#
# Check to see if my Loop tag is in there. If it is, then I want to mark
this
# message as a problem
#
LOG = "Caught a Loop: "
:0 fhw:
* ^X-MY-Loop: TAGGED
* ^Subject:\/.*
|formail -I "Subject: PM-Rule MY-Loop-> $MATCH"
# otherwise, add the TAG
:0 c:
|formail -A "X-DR-Loop: TAGGED"
#########################################################3
# Catch some auto responses messages
#
:0 fh w
* ^Auto-Submitted: auto-generated(failure)
* ^Subject:\/.*
|formail -I "Subject: PM-Rule 1 -> $MATCH"
:0 fh w
* ^Content-Type: multipart/report; report-type=delivery-status;
* ^Subject:\/.*
|formail -I "Subject: PM-Rule 2 -> $MATCH"
:0 fh w
* ^_MAILER
* ^Subject:\/.*
|formail -I "Subject: PM-Rule 3 -> $MATCH"
######################################################
#
# Collect any messages that are marked as a problem,
# and send it to my address
#
LOG = "Matched a PM Rule: "
:0:
* ^Subject: PM-Rule*
!catchall@some domain.com
#######################################################3
#
# Finally, any message that made it this far should be marked with my Loop
tag
# 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 = "Resending the message: "
:0:
!mailsort
### Eventually this will be forwarding to someone elses address, but for now
I want to see if
### any bounce messages make it past my filter.
############################## HERE IS THE PROCMAIL.LOG
#############################
----snip----
From mailsort@mydomain.com Tue Jul 12 12:07:02 2005
Subject: Returned mail: see transcript for details
Folder: /usr/sbin/sendmail -oi mailsort
10022
procmail: Assigning "UMASK=077"
procmail: Assigning "LOCKTIMEOUT=1024"
procmail: Assigning "TIMEOUT=960"
procmail: Assigning "SUSPEND=16"
procmail: Assigning "LINEBUF=4096"
procmail: Assigning "LOG=Caught a Loop: "
Caught a Loop: procmail: No match on "^X-DR-Loop: TAGGED"
procmail: Assigning "LOG=Matched a PM Rule: "
Matched a PM Rule: procmail: No match on "^Subject: PM-Rule*"
procmail: Match on ""
procmail: Extraneous locallockfile ignored
procmail: Locking ".lock"
procmail: Unlocking ".lock"
procmail: Assigning "LOG=Tagging the message: "
Tagging the message: procmail: Couldn't determine implicit lockfile from
"formail"
procmail: Locking ".lock"
procmail: Executing "formail,-A,X-DR-Loop: TAGGED"
procmail: Assigning "LASTFOLDER=formail -A X-DR-Loop: TAGGED"
procmail: Unlocking ".lock"
procmail: Assigning "LOG=Resending the message: "
Resending the message: procmail: Couldn't determine implicit lockfile from
"/usr/sbin/sendmail"
procmail: Locking ".lock"
procmail: Executing "/usr/sbin/sendmail,-oi,mailsort"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi mailsort"
procmail: Unlocking ".lock"
procmail: Notified comsat: "mailsort@:/usr/sbin/sendmail -oi mailsort"
From mailsort@mydomain.com Tue Jul 12 12:07:02 2005
Subject: Returned mail: see transcript for details
Folder: /usr/sbin/sendmail -oi mailsort
10373
procmail: Assigning "UMASK=077"
procmail: Assigning "LOCKTIMEOUT=1024"
procmail: Assigning "TIMEOUT=960"
procmail: Assigning "SUSPEND=16"
procmail: Assigning "LINEBUF=4096"
procmail: Assigning "LOG=Caught a Loop: "
Caught a Loop: procmail: No match on "^X-DR-Loop: TAGGED"
procmail: Assigning "LOG=Matched a PM Rule: "
Matched a PM Rule: procmail: No match on "^Subject: PM-Rule*"
procmail: Match on ""
procmail: Extraneous locallockfile ignored
procmail: Locking ".lock"
procmail: Unlocking ".lock"
procmail: Assigning "LOG=Tagging the message: "
Tagging the message: procmail: Couldn't determine implicit lockfile from
"formail"
procmail: Locking ".lock"
procmail: Executing "formail,-A,X-DR-Loop: TAGGED"
procmail: Assigning "LASTFOLDER=formail -A X-DR-Loop: TAGGED"
procmail: Unlocking ".lock"
procmail: Assigning "LOG=Resending the message: "
Resending the message: procmail: Couldn't determine implicit lockfile from
"/usr/sbin/sendmail"
procmail: Locking ".lock"
procmail: Executing "/usr/sbin/sendmail,-oi,mailsort"
procmail: Non-zero exitcode (69) from "/usr/sbin/sendmail"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi mailsort"
procmail: Unlocking ".lock"
procmail: Locking "/var/spool/mail/mailsort.lock"
procmail: Assigning "LASTFOLDER=/var/spool/mail/mailsort"
procmail: Opening "/var/spool/mail/mailsort"
procmail: Acquiring kernel-lock
procmail: Unlocking "/var/spool/mail/mailsort.lock"
procmail: Notified comsat: "mailsort@21570:/var/spool/mail/mailsort"
From mailsort@mydomain.com Tue Jul 12 12:07:02 2005
Subject: Returned mail: see transcript for details
Folder: /var/spool/mail/mailsort
10785
Re: Procmail recipe issue... Please help!
am 12.07.2005 19:40:48 von Allodoxaphobia
On Tue, 12 Jul 2005 12:32:16 -0400, DC wrote:
> First off: go easy, I'm a procmail newb
I.
Place these lines in your .procmailrc -- ahead of any recipes:
|# Define a newline for LOG text strings. I.e.:: LOG="text string $NL"
|NL="
|"
Yes, that's 1 line with `NL="` followed by 1 line with `"`.
Then change your "LOG=" statements to include the $NL.
E.G.:
|LOG = "Matched a PM Rule: $NL"
Makes reading your log a little easier....
II.
Why are you logging ""Caught a Loop: " and "Matched a PM Rule: "
_before_ the test for same?
E.G.:
:
|
|# 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
| }
:
No lock (:0:) needed in the example above -- thus (:0).
(Please Use the universally agreed upon example.com for a
domain name in all usenet postings of make-believe email addys.
Ref: http://example.com/
No, invalid.com is not a substitute. Ref: http://invalid.com/ )
'Neaten Up" your source -- to prevent you and us from getting cross-
eyed reading it, and to improve understandability 6 months from now
when you try to figure just what the ^%]&%$! you were thinking when
you originally coded. it.
Purely blank lines:
|
are the same as empty comment lines:
|#
and help break up the recipes into readable chunks.
I know you are having other problems, but others - more expert than me
me - are no doubt typing up and posting their replies as I type this.
So, I thought I'd take some of the 'easy stuff'. :-)
HTH...Some
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
Pueblo, Colorado | @ | Jonesy | OS/2 __
38.24N 104.55W | config.com | DM78rf | SK
Re: Procmail recipe issue... Please help!
am 12.07.2005 20:09:49 von Oliver Weichhold
On 12 Jul 2005 17:40:48 GMT, Allodoxaphobia
wrote:
>On Tue, 12 Jul 2005 12:32:16 -0400, DC wrote:
>> First off: go easy, I'm a procmail newb
>
>I.
>Place these lines in your .procmailrc -- ahead of any recipes:
>
> |# Define a newline for LOG text strings. I.e.:: LOG="text string $NL"
> |NL="
> |"
Good call..
I did try using a "\n" but that didn't work.
>
>Yes, that's 1 line with `NL="` followed by 1 line with `"`.
>Then change your "LOG=" statements to include the $NL.
>E.G.:
> |LOG = "Matched a PM Rule: $NL"
>
>Makes reading your log a little easier....
>
>II.
>Why are you logging ""Caught a Loop: " and "Matched a PM Rule: "
>_before_ the test for same?
I realized I did that right after I ran it the first time. Just never
got around to fixing it. still gives me a general idea of where in the
script i am.. although if i looked six months from now, i really would
confuse the hell out of myself.
>E.G.:
> :
> |
> |# 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
> | }
> :
>
>No lock (:0:) needed in the example above -- thus (:0).
Ok, wasn't sure if i needed it or not. When in doubt, use a lock file
right?
>
>(Please Use the universally agreed upon example.com for a
>domain name in all usenet postings of make-believe email addys.
>Ref: http://example.com/
>No, invalid.com is not a substitute. Ref: http://invalid.com/ )
Note taken.
>
>'Neaten Up" your source -- to prevent you and us from getting cross-
>eyed reading it, and to improve understandability 6 months from now
>when you try to figure just what the ^%]&%$! you were thinking when
>you originally coded. it.
Yeah, i thought it was going to be a quick / short thing... im
cleaning up now.
>
>Purely blank lines:
> |
>are the same as empty comment lines:
> |#
>and help break up the recipes into readable chunks.
>
>I know you are having other problems, but others - more expert than me
>me - are no doubt typing up and posting their replies as I type this.
>So, I thought I'd take some of the 'easy stuff'. :-)
>
>HTH...Some
>Jonesy
Re: Procmail recipe issue... Please help!
am 12.07.2005 20:24:55 von Oliver Weichhold
OK, here is my new files
Right now im getting error messages that come back saying "too many
hops".
I think it is from the section commented as "otherwise, add the TAG"
Is it creating a new copy of the message without the header i just
added???
######### .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.
######### 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
procmail: Skipped "|formail -I "Subject: PM-Rule 1 -> $MATCH""
procmail: No match on "^Content-Type: multipart/report;
report-type=delivery-status;"
procmail: Extraneous filter-flag ignored
procmail: Extraneous deliver-head flag ignored
procmail: Skipped "|formail -I "Subject: PM-Rule 2 -> $MATCH""
procmail: No match on "^_MAILER"
procmail: Extraneous filter-flag ignored
procmail: Extraneous deliver-head flag ignored
procmail: Skipped "|formail -I "Subject: PM-Rule 3 -> $MATCH""
procmail: No match on "^Subject: PM-Rule*"
procmail: Skipped "!catchall@example.com"
procmail: Match on ""
procmail: Extraneous locallockfile ignored
procmail: Locking ".lock"
Re: Procmail recipe issue... Please help!
am 12.07.2005 21:37:24 von Allodoxaphobia
On Tue, 12 Jul 2005 14:09:49 -0400, DC wrote:
> On 12 Jul 2005 17:40:48 GMT, Allodoxaphobia
> wrote:
>>
>>Why are you logging ""Caught a Loop: " and "Matched a PM Rule: "
>>_before_ the test for same?
>
> I realized I did that right after I ran it the first time. Just never
> got around to fixing it. still gives me a general idea of where in the
> script i am.. although if i looked six months from now, i really would
> confuse the hell out of myself.
I see. My General Rule is to use something of the
ilk:
|LOG=">>DEBUG: enter PM-Rule. Last Match=$MATCH $NL"
:
:
|LOG=">>DEBUG: exit PM-Rule. Last Match=$MATCH $NL"
Thataway I can easily [F]ind them with the editor (or with grep, ...)
and comment them out after debugging/troubleshooting.
> Ok, wasn't sure if i needed it or not. When in doubt, use a lock file
> right?
Strcitly? Wrong. You'll see a procmail in your log for each
superfluous one.
>>'Neaten Up" your source -- to prevent you and us from getting cross-
>>eyed reading it, and to improve understandability 6 months from now
>>when you try to figure just what the ^%]&%$! you were thinking when
>>you originally coded. it.
>
> Yeah, i thought it was going to be a quick / short thing... im
> cleaning up now.
I've been in This Business way too long (since 1966.)
A Quick-and-Dirty hack does _not_ mean it's a short-lived,
never-to-be-updated-ever-again piece of logic.
Been there.
Done that.
Suffered embarassment many times.
'Tis fun, tho'. Isn't it?
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
Pueblo, Colorado | @ | Jonesy | OS/2 __
38.24N 104.55W | config.com | DM78rf | SK
Re: Procmail recipe issue... Please help!
am 12.07.2005 23:14:35 von Oliver Weichhold
On 12 Jul 2005 19:37:24 GMT, Allodoxaphobia
wrote:
>On Tue, 12 Jul 2005 14:09:49 -0400, DC wrote:
>> On 12 Jul 2005 17:40:48 GMT, Allodoxaphobia
>> wrote:
>>>
>>>Why are you logging ""Caught a Loop: " and "Matched a PM Rule: "
>>>_before_ the test for same?
>>
>> I realized I did that right after I ran it the first time. Just never
>> got around to fixing it. still gives me a general idea of where in the
>> script i am.. although if i looked six months from now, i really would
>> confuse the hell out of myself.
>
>I see. My General Rule is to use something of the
>ilk:
> |LOG=">>DEBUG: enter PM-Rule. Last Match=$MATCH $NL"
> :
> :
> |LOG=">>DEBUG: exit PM-Rule. Last Match=$MATCH $NL"
>
>Thataway I can easily [F]ind them with the editor (or with grep, ...)
>and comment them out after debugging/troubleshooting.
>
>
>
ahh yeah a prefix would have been a good idea..
One a got rid of my :0 problems the log file got MUCH smaller though
haha.
>> Ok, wasn't sure if i needed it or not. When in doubt, use a lock file
>> right?
>
>Strcitly? Wrong. You'll see a procmail in your log for each
>superfluous one.
>
>
Yeah, my new one actually has no lock files anymore
>>>'Neaten Up" your source -- to prevent you and us from getting cross-
>>>eyed reading it, and to improve understandability 6 months from now
>>>when you try to figure just what the ^%]&%$! you were thinking when
>>>you originally coded. it.
>>
>> Yeah, i thought it was going to be a quick / short thing... im
>> cleaning up now.
>
>I've been in This Business way too long (since 1966.)
>A Quick-and-Dirty hack does _not_ mean it's a short-lived,
>never-to-be-updated-ever-again piece of logic.
>Been there.
> Done that.
> Suffered embarassment many times.
>
>'Tis fun, tho'. Isn't it?
>
>Jonesy
Ha, I here you. I should have known... 90% of my "quick hack scripts"
and up becoming more of 6+ pages of extremely sloppy code.
Here is my new procmail, incase anyone is interested.
################## .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
* ^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 DR-Loop-> subject
#
:0
*
{
LOG = "Passed All Filters$NL"
:0 fhw
* ^Subject:\/.*
|formail -I "Subject: PASSED Filter -> $MATCH"
:0
!catchall@example.com
}
################## procmail.log ####################
## Well, it was really clean untill i added that crazy looking
## FROM_MAILER rule in it... word wrap don't help either.
procmail: Assigning "UMASK=077"
procmail: Assigning "LOCKTIMEOUT=1024"
procmail: Assigning "TIMEOUT=960"
procmail: Assigning "SUSPEND=16"
procmail: Assigning "LINEBUF=4096"
procmail: Assigning "NL=
"
procmail: No match on "^X-DR-Loop: TAGGED"
procmail: Match on ! "^X-DR-Loop: TAGGED"
procmail: Assigning "LOG=Adding a Loop tag
"
Adding a Loop tag
procmail: Executing "formail,-A,X-DR-Loop: TAGGED"
procmail: No match on "^Auto-Submitted: auto-generated\(failure\)"
procmail: No match on "^Content-Type: multipart/report;
report-type=delivery-status;"
procmail: No match on
"(^(((Resent-)?(From|Sender)|X-Envelope-From):|>?From
)([^>]*[^(.%@a-z0-9])?(Post(ma(st(er)?|n)|office)|(send)?Mai l(er)?|daemon|mmdf|n?uucp|ops|r(esponse|oot)|(bbs\.)?smtp(er ror)?|s(erv(ices?|er)|ystem)|A(dmin(istrator)?|MMGR))(([^).! :a-z0-9][-_a-z0-9]*)?[%@>
][^<)]*(\(.*\).*)?)?$([^>]|$))"
procmail: No match on "^Subject: PM-Rule*"
procmail: Match on ""
procmail: Assigning "LOG=Passed All Filters
"
Passed All Filters
procmail: Assigning "MATCH="
procmail: Matched " slkdfj"
procmail: Match on "^Subject:\/.*"
procmail: Executing "formail -I "Subject: PASSED Filter -> $MATCH""
procmail: Executing "/usr/sbin/sendmail,-oi,catchall@example.com"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi
catchall@example.com"
procmail: Notified comsat: "mailsort@:/usr/sbin/sendmail -oi
catchall@example.com"
From dcasey@example.com Tue Jul 12 16:44:49 2005
Subject: PASSED Filter -> slkdfj
Folder: /usr/sbin/sendmail -oi catchall@example.com
847