procmail
[Top] [All Lists]

Re: Forward mail to another address while retaining in INBOX

2002-04-07 23:28:21
"gaukia 345" <gaukia(_at_)hotmail(_dot_)com> writes:
I\x92m writing a webmail using PHP 4.1.2. I use Uwash IMAP server. I would 
like 
to write a procmail recipe that forwards a mail to another email address in 
addition to originally intended recipient. Example: Alice sends to Bob. When 
the email reaches Bob\x92s host, one mail is stored in Bob\x92s mailbox 
(INBOX) 
and procmail recipe sends the same mail to Charles.

I\x92ve come up with 2 recipes based on examples provided in FAQs on the Net. 
Which one is more preferable?

:0                     # That's colon, zero
* ^TO_db(_at_)cik-ah\(_dot_)uniten\(_dot_)edu\(_dot_)my
! db(_at_)ddd(_dot_)edu(_dot_)my anotherguy(_at_)abc(_dot_)com # That's 
exclamation mark, address to 
forward to

OR

:0c                    # That's colon, zero, lowercase cee
* ^TO_db
! anotherguy(_at_)abc(_dot_)com        # That's exclamation mark, address to 
forward to

The latter is to be prefered, partly because it saves a procmail process,
but mainly because it reduces the chance of a direct loop substantially.
Indeed, since the first recipe doesn't actually alter the message, if the
db(_at_)ddd(_dot_)edu(_dot_)my address is handled by this rcfile, then it'll 
loop, period.

Even better is to
a) put the recipe in relevant user's .procmailrc andjremove the ^TO_
   condition, and
b) add a condition that refuses to forward the message if it has an  
   X-Loop: header with this user's address in it and add just such a
   header to the outgoing message.

So, if the db user's .procmailrc, put the recipe:

        :0 c
        * ! ^X-Loop: db(_at_)cik-ah\(_dot_)uniten\(_dot_)edu\(_dot_)my
        | formail -A "X-Loop: db(_at_)cik-ah(_dot_)uniten(_dot_)edu(_dot_)my" | 
\
          $SENDMAIL $SENDMAILFLAGS anotherguy(_at_)abc(_dot_)com

You should probably also add a condition
        * ! ^FROM_MAILER
to avoid forwarding bounce message and the like.  (What happens if
anotherguy(_at_)abc(_dot_)com bounces because of a transient failure?)


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>