procmail
[Top] [All Lists]

Re: Redirect to two persons

2006-01-31 13:56:47
At 17:54 2006-01-31 -0200, JEMF wrote:
Professional Software Engineering escreveu:

First, WHERE is your procmail rule - in a personal ~/.procmailrc, or in
/etc/procmailrc ?

/etc/procmailrc

# note DOT is escaped, and headers are ANCHORED and have trailing colons
:0
* ^To:(_dot_)*sector1(_at_)internal
* ^From:(_dot_)*(_at_)external\(_dot_)com
!sector2,sector3

This forwards the message to the other two mailboxes.  If they're 
likely to
bounce mail back into the sector1 mailbox, you should add loop checking,
for example:

This configuration produces loops and the message "Folder:
/usr/sbin/sendmail -oi sector2,sector3".

Well, yea, if it's being processed without loop checking AND you're doing 
the filter check in /etc/procmailrc, since ALL system mail (including the 
mail going to sector2 and sector3, if local users), will run through the 
filter again.

I wrote the above filter with the assumption that you were filtering in 
~/.procmailrc for user sector1

If you want to filter in /etc/procmailrc, try adding the following at the 
top of the condition block:

* ? $LOGNAME ?? ^^sector1^^


Where "sector1" is the actual username of the account that the sector1 mail 
is delivered to.  This will limit that recipe to being invoked only when 
the mail is for that actual user.


BTW, I neglected to point out that your original recipe lacked locking on 
the delivery to the two mailboxes you were writing directly to:

if you're going to write directy to a mailbox file (be it in a user 
directory, or a mailspool):

         :0
         /var/mail/sector3

you should do it like so:

         :0:
         /var/mail/sector3

that trailing colon is a flag that invokes file locking.  Without it, if 
you get two messages that are being processed at the same time, the mailbox 
can become corrupted with part of one message, and part of another, then 
part of the first, etc.

---
  Sean B. Straw / Professional Software Engineering

  Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
  Please DO NOT carbon me on list replies.  I'll get my copy from the list.


____________________________________________________________
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>