procmail
[Top] [All Lists]

Re: ok, how do I get this to work (recipe needed)

1996-06-03 19:05:37
Larry Glaze <glaze(_at_)rclsgi(_dot_)eng(_dot_)ohio-state(_dot_)edu> writes:
Ok, procmail is still having fits and refuses to save out a mail message
under the name filename I specify (I want each message to have a unique
name).  So, I have an idea, but don't know how to get it to work after
several tries.  Here is the deal, I can get procmail to save out the
message as an MH mail foder in a directory I specify.  The recipe is simple
and looks like this:

:0
* ^To:.*some account*
testmail/.

1) The trailing '*' is wrong.  Remove it.
2) Do you want to procmail to keep reading the procmailrc if the above
   recipe above succeeds?  Then you'll need to give it the 'c' flag, and
   possibly nest this in a block.
3) Why are you matching on the To: header?
   a) This account is the target of a virtual domain and you only want to
      do this stuff for mail to one of the addresses in the virtual account,
      in which case you should hack the sendmail.cf to pass in the envelope
      recipient as a seperate header, and match on that.
   b) You only want to process messages send directly to this account,
      not cc'ed or sent via a mailing lists, in which this is right thing.
   c) Something else, in which case it probably isn't doing what you think
      it is.  Why are you doing this?


This will save each message in the testmail directory under a unique number.
Now, I noticed that it assigns the path and unique number to the LASTFOLDER
variable.  Now, I have a script which I want to execute upon the message
and do various things with it depending upon what is in the body of the
message.  It's recipe looks something like this:

:0
FROM=`formail -rx To:`
|/some/path/to/script/script.pl $FROM $LASTFOLDER

This doesn't look like a recipe to me.  FROM=.... is *not* a condition,
and the recipe syntax only allows for one action line, so the above is
a syntax error, and procmail will probably ignore the |/some/path.... line.


Here, I just extract who sent the mail and pass that, along with the contents
of LASTFOLDER, to the script.  So, my question is this: how do I set this up
such that if someone sends mail to *some account*, the message will
get written out and then the FROM variable will be assigned, plus, the script
will be ran with the given arguments?  I tried using {...} to do nesting,
but I must have done it wrong because it would always skip the 'testmail/.'
part (all of the above was in the braces except the first :0 and *some account*
part.  

The braces just contain recipes.  You have to have another ":0" recipe
leader on the inside, ala:

:0
* ^To:.*some account([^-a-z0-9_.]|$)
{
    # Do the delivery, but keep going
    :0 c
    testmail/.

    # extract the source address
    FROM=`formail -rx To:`

    # feed the script
    :0
    |/some/path/to/script/script.pl $FROM $LASTFOLDER
}


Think about it; do you understand how the above works?  If not, go back
and read the first two pages of the procmailrc(5) manpage carefully while
staring at the recipe.

Finally, why do some people feel that they have to hide login and 
path names?

Philip Guenther

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