procmail
[Top] [All Lists]

Modified forwarding

1996-05-21 17:49:30
Hi folks,

Here is a problem which I face.  I get mail from different folks, which are 
supposed to be processed by a third party (user3(_at_)foo(_dot_)com).  
Originally, I 
did this

:0
* ( check whether forwarding conditions exist )
{
    MAILDIR = $HOME/fileserver
    (1st recipe - generate an acknowledgement to the sender)    
    :0
    ! user3(_at_)foo(_dot_)com
}

The above set-up works, but user3(_at_)foo(_dot_)com can get confused between 
regular mail from me and the forwarded messages, which should be processed
promptly.  So I did the following.

:0 w
* ( check whether forwarding conditions exist )
{
    MAILDIR = $HOME/fileserver
    FROM = `formail -xFrom:`
    TO = `formail -rt -xTo:`
    DATE = `formail -xDate:`
    SUBJECT = `formail -xSUBJECT:`

    (1st recipe - generate an acknowledgement to the sender)    

    :0 b: User1Lck
    | cat - > tmpFile1                                           \
    | echo "User $FROM\n"                                        \
           "on $DATE\n"                                          \
           "sent a message to me.\n"                             \
           "Please process and reply to $TO\n"                   \
           "The message received is given below\n"               \
           "-------------------------------------\n"             \
           2>&1                                                  \
    | cat ./HEADERFILE - 2>&1 tmpFile1                           \
    | formail -I "To:" -a "To: Third party <user3(_at_)foo(_dot_)com>"      \
              -I "Subject:" -a "Subject: (special fwd) $SUBJECT" \
              -I "Reply-To:" -a "Reply-To: $TO"                  \
    | $SENDMAIL -oi -t
}

This works, but seems to be a lot of code and I am tentative about
the file (tmpFile1) created.  Here are my questions

1) Is there a simpler way to do the same thing?
2) Will the wait at the top level (:0 w) and 
   the lock at the recipe level (:0 b: User1Lck) 
   insure that if two messages simultaneously get to my id,
     they will not clobber each other 
          by writing to the same file (tmpFile1)?

Thanks for any response.

Das Devaraj
-------------------------------------------------------------------
Interested in Vegetarianism?             Vegetarian Restaurant Trek
Web    http://www.VegInfo.com                712 Bancroft Road #320
e-mail info(_at_)VegInfo(_dot_)com (subject Help)       Walnut Creek, CA 94598
Interactive Voice/fax Response  (510) 256-8420                  USA

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