procmail
[Top] [All Lists]

Re: Autoreply of processed messages

1998-05-26 03:19:35
On Tue, 26 May 1998 10:56:32 +0200 (SAT),
Dirk Laurie <dirk(_at_)calvyn(_dot_)puk(_dot_)ac(_dot_)za> wrote:
On Tue, 26 May 1998 10:56:32 +0200 (SAT),
Dirk Laurie <dirk(_at_)calvyn(_dot_)puk(_dot_)ac(_dot_)za> wrote:
SENDMAIL = /usr/sbin/sendmail

(Are you sure you need to reset Procmail's compiled-in notion of where
Sendmail resides? What if your ISP moves Sendmail without telling you?)

:0
* !^FROM_DAEMON
* !^X-Loop: $USER(_at_)$HOST

You need a $ option on recipes when you want $VAR references to be
interpolated. Also note that $\VAR is useful here for quoting
characters that are special to Procmail.

    :0
    *   ! ^FROM_DAEMON
    * $ ! ^X-Loop: $\USER(_at_)$\HOST
    { # ...

{ # shell script `pipe` sends stdout if exit code 0, else stderr   

(Not sure what this means. The exit code of what? Do you mean the idea
is to throw away the body under some circumstances?)

  :0 fbw :
  | pipe
<...>
I'm not too sure it works if mails come thick and fast: `pipe` uses
temporary file names that are not unique, and I'm hoping that the second
colon on its recipe stops a new mail from executing the recipe until the
first one is finished.

It will not; in fact, you will get an error message in the log stating
that Procmail can't figure out what to lock. Use a named lock file
each time you use the pipe script -- the same lock file each time,
otherwise different invocations of pipe will clobber each others' temp
files. Better yet, rewrite pipe so it uses unique temp file names, or
no temp files at all. Hint: $$ contains the PID of the current process.

  :0 fhw              # reverse mailheader and extract name
  | formail -rA "X-Loop: $USER(_at_)$HOST"
  :0 a
  | $SENDMAIL -oi -t
}
:0
/dev/null

You mean all mail that didn't go into the braces should go to
/dev/null? I wouldn't do that, at least not until I'm +very+ sure the
script is properly debugged. Even then, it would seem useful to get a
warning that there is a mail loop, or that some bozo is mailing to the
wrong address.

Note also that if formail fails for some reason, mail will get sent to
/dev/null. (And possibly you should be using formail -rt instead of
just -r.)

Hope this helps,

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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