procmail
[Top] [All Lists]

Re: How can procmail handle multiple names

1996-07-21 13:44:48
Leif Erlingsson suggested to Brett Schlank:

| SAVELASTFOLDER=$LASTFOLDER
| LOGABSTRACT=no
| 
| :0
| * ^TO(jim|al|charles)@mydomain.com
| * !^TO yourself(_at_)mydomain(_dot_)com
| * LASTFOLDER ?? .
| /dev/null
| 
| LOGABSTRACT=all
| LASTFOLDER=$SAVELASTFOLDER

| What it does? Well, *IF* the msg was to one or several of the other guys,
| and not to You, and it indeed has been delivered somewhere already
| (that's a safety precaution ... the * LASTFOLDER ?? .    stuff), then drop
| the carbon copy or copies to the bit bucket. The SAVELASTFOLDER=$LASTFOLDER
| and LOGABSTRACT=no stuff turns off logging and prevents LASTFOLDER to be set
| to /dev/null. It is all turned back on again after this recepie.

Actually, if LASTFOLDER is set to /dev/null, it means that the recipe that
dumps to /dev/null was used, and then procmail doesn't read the reassignment
of LASTFOLDER=$SAVELASTFOLDER.  Procmail pretty much keeps $LASTFOLDER right
without effort by the coder; if Brett doesn't want to see the dump to
/dev/null in his logfile, turning LOGABSTRACT off as Leif showed is enough:

  :0 # put easiest condition to test first to reduce effort if possible
  * LASTFOLDER ?? .
  * ^TO(jim|al|charles)@mydomain\.com
  * !^TObschlank\>
  {
   LOGABSTRACT=no

   :0h
   /dev/null
  }

Actually, if there are no more rcfiles named on the command line, this is a
perfect use for procmail's built-in bit bucket:

  :0
  * LASTFOLDER ?? .
  * ^TO(jim|al|charles)@mydomain\.com
  * !^TObschlank\>
  { TRAP='' HOST=wR_on!G+name }

A mismatching HOST assignment with no more rcfiles left on the command line
causes an immediate exit without a logabstract.  (It does still run the trap
statement, so first we make that null.)

Leif also had a very good point that the message might also be addressed to
Brett as well as to Jim, Al, or Charles.  In my earlier answer, I didn't
think of that.  (Brett's original code, at least as he showed it with his
question, didn't allow for it either.)  I figured that Brett would either
want or not want such mail in his own folders without considering that he
might want some of it yet not all of it.

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