Martin Schmitt <[EMAIL PROTECTED]> writes:

> When a new message has arrived, I want Procmail to execute a script that
> does an SSH to my home machine and tells it to run fetchmail.
> 
> A peek into my .procmailrc:
> 
> # Run the message through tmda-filter.
> :0 w
> | /opt/tmda/bin/tmda-filter
> 
> # Take the exit code from TMDA.
> EXITCODE=$?
> 
> # TMDA takes care of final delivery
> DEFAULT=/dev/null
> 
> How can I tell if TMDA is going to / has delivered a message?

Assuming your ISP is *not* running qmail, how about this in your
.procmailrc, instead:

/--------
# Run the message through tmda-filter.
:0 Wf
| /opt/tmda/bin/tmda-filter -p

EXITCODE = $?

  :0 a
  {
    # Deliver to the mailbox at your ISP.
    :0 c : [some_lock_file]
    $HOME/mailbox

    # Procmail should consider this a "delivering" recipe and stop.
    :0 i
    | /path/to/your/ssh/alert_me.sh
  }

:0
* EXITCODE ?? 99
{
  EXITCODE = 0
}

DEFAULT = /dev/null
\--------


I have no idea if that will work "as is".  I don't use procmail.
However, the basic idea is that, when tmda-filter is invoked as a
filter (the -p option) it will return 0 and print the message to
stdout if it determines the message should be delivered.  The 'f' flag
on the first recipe tells procmail to expect this.

The 'a' flag on the second recipe says to do the following block only
if the previous recipe was successful (i.e., tmda-filter returned 0).
Since tmda-filter is no longer doing the delivery, you need to store
the message wherever tmda-filter previously would have stored it.
Then, you can invoke your script, feeding it the message (which it can
ignore without error because of the recipe's 'i' flag).  Your script
would make the SSH connection to your home machine.

If I understand procmail's docs correctly, if a program absorbs a
message and the recipe didn't have the 'f', 'w', 'W' or 'c' flags,
procmail considers the message delivered and then stops.

The final recipe should only happen if tmda-filter returned something
other than 0.  It says that if tmda-filter returned 99 (because of a
bounce, confirm or drop, for example), procmail's exit code should be
reset to 0, since no MTA but qmail understands the 99.

If tmda-filter had a processing error, it returns 75 and you want to
leave that alone, so that procmail returns the 75 to the MTA and the
message is requeued for a later delivery attempt.  tmda-filter will
have written a debugging report to your debug log (or
~/TMDA_DELIVERY_FAILURE) in that case.

The important point is, you must do delivery yourself with
tmda-filter's -p option, because any time that tmda-filter determines
a delivery is necessary, it writes the message to stdout, ignoring any
specific delivery destination, whether given in a filter rule or in
the DELIVERY configuration variable.


Tim

_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to