procmail
[Top] [All Lists]

Re: [Addendum] recipe problem

2001-10-09 22:12:41
Justin Shore <listuser(_at_)neo(_dot_)pittstate(_dot_)edu> writes:
Ok, I think I may have it now.

:0
* ^From snip(_at_)snip
{
        SUBJECT=`formail -zxSubject:`

        :0c:formail.lock
        | expand | sed -e 's/[ ]*$//g' | sed -e 's/^/ /' > return.tmp

        :0c
        * !   ^FROM_DAEMON
        * ! $ ^X-Loop: $\ABUSE
        | (formail -r \
         -I"From: Abuse redirect <postmater(_at_)snip(_dot_)net>" \
         -I"To: junk <snip(_at_)snip>" \
         -I"Subject: [REDIRECT] $SUBJECT" \
         -A"X-Loop: $ABUSE" ; \
        /bin/cat "/etc/mail/abuse/swb-65-66-91-253.txt" ;\
        cat return.tmp;\
        rm -f return.tmp ; ) \
        | $SENDMAIL -t

        :0:
        /var/spool/mail/quarantine/test
}

Um, that'll always send the messages to junk <snip(_at_)snip>.  The -r flag
to formail is almost (but not quite) pointless.  You should clarify what
you're trying to do with that formail command.

The locking isn't correct on that.  You would need to hold the lock
from before the first nested recipe to after the second and you're only
holding it during the first.

Rather that take and hold a lock like that, I would tend to capture the
return header in a variable and then output it with echo, like this:

        :0
        * ^From snip(_at_)snip
        {
                # extract the Subject without using an outside command
                :0
                * ^Subject:[    ]*\/[^  ](.*[^  ])?
                { }
                subject = "Subject: [REDIRECT] $MATCH"

                # Variables for convenience and efficiency
                ## (is that supposed to be 'postmaster'?)
                from = "From: Abuse redirect <postmater(_at_)snip(_dot_)net>"
                to = "To: junk <snip(_at_)snip>"

                # Generate a reply header (I don't think this formail
                # command is 100% correct)
                :0 hw
                * !   ^FROM_DAEMON
                * ! $ ^X-Loop: $\ABUSE
                header=| formail -r \
                        -I"$from" -I"$to" -I"$subject" \
                        -A"X-Loop: $ABUSE"

                # If that worked...
                :0 abcw
                | ( echo "$header" ; \
                    cat "/etc/mail/abuse/swb-65-66-91-253.txt" ; \
                    expand | sed -e 's/[ ]*$//g' -e 's/^/ /' \
                  ) | $SENDMAIL $SENDMAILFLAGS -t
                
                # Always save a copy
                :0:
                /var/spool/mail/quarantine/test
        }


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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