procmail
[Top] [All Lists]

Re: procmail fails

1996-07-10 23:10:12
On Wed, 10 Jul 1996, Philip Guenther wrote:

Daniel Stenberg <Daniel(_dot_)Stenberg(_at_)sth(_dot_)frontec(_dot_)se> 
writes:
It is supposed to find 'dastmail' in the To: field and then execute the
commands I want. It does, and when I try it on a shell command line it
works OK, but procmail (or rather some other subprocess) fails with the
message 'Error: can't find file to!'

What's the problem?

It would help to be able to see the recipes involved here.

Thanks for taking some time off to help!

My top of my .procmailrc looks like:
------------------------------------------------------
VERBOSE=on
SUBJECT=`sed -n -e "s/Subject: \(.*\)/\1/1p"`
FROM=`sed -n -e "s/From: \(.*\)/\1/1p" | tr -d \"`
TO=`sed -n -e "s/To: \(.*\)/\1/1p"`
#
# The name(_at_)site(_dot_)domain part of the address:
FROMA=`echo $FROM | sed -e "s/\(.*[ ]\)//p" | tr -d '><'`
#
# Log all incoming mail events.
#
:0 c
| date +"%D %T Mail from <$FROM> about <$SUBJECT>" >>Mail/.log
#
# Do the mail machine
#
:0
* ^To.*dastmail@
| /home/metal/dast/bin/metamail -q | \
  /home/metal/dast/bin/frexxedm \"$SUBJECT\" \"$FROM\"

------------------------------------------------------

And I typical testmail for this, may look like:

------------------------------------------------------
From dast(_at_)sth(_dot_)frontec(_dot_)se Wed Jul 10 11:02:08 1996
Date: Wed, 10 Jul 1996 11:02:06 +0200 (MET DST)
From: Daniel Stenberg <dast(_at_)sth(_dot_)frontec(_dot_)se>
X-Sender: dast(_at_)metal
To: List <dastmail(_at_)sth(_dot_)frontec(_dot_)se>
Subject: TESTMESSAGE
Message-ID: 
<Pine(_dot_)SOL(_dot_)3(_dot_)94(_dot_)960710110049(_dot_)8927A-100000(_at_)metal>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Status: RO
X-Status: 
 
This is a test message.
------------------------------------------------------

I will note you probably should be using formail instead of sed to
extract into the FROM variable, ala:

FROM=`formail -rtx To:`
That's straight off of the procmailex(5) manpage, and correctly handles
From: vs. Sender: vs. Reply-To:, etc.

I know, these are only my first tests and I got quite bored by the fact
that 'formail' includes the initial whitespace as a part of the field it
extracts. I guess I should make a formail first and then strip the initial
space to get the best result...

What if the message doesn't even _have_ a To: header?
What are you going to use it for?

Your missing the point. If it is gonna say 'Error: can't find file to!'
it doesn't matter if the whole mail is stuffed with 200 To:-lines, my
program won't run anyway. This is only a test setup and I will indeed
consider to use proper 'formail' calls.

If I replace the command line of the '.*dastmail' to a simple
"| echo $SUBJECT $FROM >junk" it works like a charm, and also the other
pattern matches/actions I use and have tried work nicely. Left is now only
that weird error message on that single pattern match... As for now, I'm
still left with my lame 'filter' setup! ;(

MORE debug information:

If I replace the command line and use:

| /home/metal/dast/bin/metamail -q | \
  trace /home/metal/dast/bin/frexxedm \"$SUBJECT\" \"$FROM\"

I can see that the 'frexxedm' program exits due to a - SIGCHLD (20) 
signal. But that signal comes after while, which confuses me...

Just piping in the mail on a shell prompt works of course very well.

     Daniel(_dot_)Stenberg(_at_)sth(_dot_)frontec(_dot_)se    IRC: Bagder
     http://sunsite.auc.dk/frexxed     FrexxWare - Products for cool users.
      ** Works for http://www.frontec.se - Software Engineer **

<Prev in Thread] Current Thread [Next in Thread>