procmail
[Top] [All Lists]

Re: Help Please

1997-04-02 23:40:00
grenleaf <grenleaf(_at_)bom2(_dot_)vsnl(_dot_)net(_dot_)in> writes:
After reading manual pages for procmail, procmailex, procmailrc,
procmailsc, sendmail etc... 
pages we have tried to create a recipe. What it does is, if someone sends
us a mail with the 
word `cprofile' in the subject, first it would mail me at my new address,
second it should send
back the content of file `ctest' to the sender. If the word `cprofile' is
not found it would
simply forward the mail to my new address.

---- Recipe Starts Here ----

#a/h/a/haripati/.procmail/rc.testing

:0 c
* ^Subject:.*cprofile
! grenleaf(_at_)bom2(_dot_)vsnl(_dot_)net(_dot_)in

:0 
* ^Subject:.*cprofile
| ( formail -r ; cat ctest ) | $SENDMAIL -oi -t 

    :0 E
    ! grenleaf(_at_)bom2(_dot_)vsnl(_dot_)net(_dot_)in

---- Recipe Ends Here ----

My Problem :
Now suppose we receive a mail with the word `cprofile' in subject field.
It successfully passes
the message to my new email address. But does not pass the content of the
file `ctest' to the
sender. Where are we going wrong. I have created `ctest' file in my $HOME
directory and also
inside the "$HOME/.procmail/"
...
My "log" files reads as follows :
...
cat: ctest: No such file or directory
...


You should either you a full path to specify the location of 'ctest' or
put it in the $MAILDIR directory, that being where procmail is chdir'ed
to.  Using the full path is usually the better choice if you're not sure
what future changes you're going make.

My second comment is to note that you should be testing for and creating
an X-Loop: header to avoid mail loop problems.  See below for an example.
For paranoia we'll also refuse to send auto-replies to daemons.

Finally, since you're always going to forward the message to your new
address, you can move that recipe to the bottom and make it conditionless,
ala:

# Since formail only needs the header of the incoming message to generate
# the reply header, we'll add the 'h' flag to save the work of writing the
# body down a pipe to a process that'll ignore it.
:0 ch
*   ^Subject:.*cprofile
* ! ^FROM_DAEMON
* ! ^X-Loop: haripati(_at_)cyberspace\(_dot_)org
| ( formail -rA"X-loop: haripati(_at_)cyberspace(_dot_)org"; \
        cat $HOME/.procmail/ctest ) | $SENDMAIL -oi -t 

:0
! grenleaf(_at_)bom2(_dot_)vsnl(_dot_)net(_dot_)in


That all make sense?  More importantly, do you understand the purpose
behind it all?

Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>
  • Help Please, grenleaf
    • Re: Help Please, Philip Guenther <=