procmail
[Top] [All Lists]

RE: Append header in undelivered messages

2007-11-05 17:12:50
Xesc Arbona wrote Monday, November 05, 2007 10:42 AM:

[Dallman Ross wrote:]
Try breaking up the recipes into stages so you know just what it
is that didn't work.

  :0 fw
  * condition
  | formail -A "X-Loop: xesca(_at_)topdesk(_dot_)com"

  :0 a
  *condition
  ! forwarding(_at_)address(_dot_)dom

Thank you very much for your help, and sorry for not 
including my recipes before. The problem was in fact that I 
was adding the header and sending the message with $SENDMAIL 
in the same action line. Splitting them in two and adding 
some fixes solved the issue. The following recipes work now for me:

Glad the fix worked.

## Check duplicates
:0 Wh: $PMCACHE/$RECIPIENT.msgid.lock
* ! ^X-Loop:.*

You don't need the trailing ".*".  But if others are
also using X-Loop, you will false-poz on this.  Put
in the email address or string you used when creating
your X-Loop before sending out.

* ! ^Delivered-To.*PUB_.*@
| formail -D 4096 $PMCACHE/$RECIPIENT.idcache

## Error control
:0 e
{
  # Get exitcode from delivery agent
  :0
  { EXITCODE=$? }
  # Send a copy of the mail only if not already sent, 
  # not a PUBlic folder and not a permament error
  :0
  * ! ^X-Loop:.*
  * ! ^Delivered-To.*PUB_.*@
  * ! EXITCODE ?? 70

Same comment about ".*" after X-Loop: and using the actual
string as opposed to leaving it off.

You already did these conditions above.  You ought to
be able to combine steps.  For exampl,e put this after
the dupe-check recipe and use the "a"-flag.

  {
     :0 fw
     | formail -I Delivered-To -a "X-Loop: $RECIPIENT(_at_)mydomain(_dot_)com"

     :0 a
     # Set EXITCODE=0 to not return the current message to MTA queue.
     # Copied message with X-Loop will do
     { EXITCODE=0 }

     :0 a
     | $SENDMAIL -oi -f $SENDER $RECIPIENT

Also, "-oi" is the default for $SENDMAILFLAGS, which
you could use instead if you wanted.

  }
}

Dallman
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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