procmail
[Top] [All Lists]

Re: procmail - a condition .. LOOPING OOPS

2005-01-11 09:10:13

Okay, but how about just trying to switch to the
putative local
user's .procmailrc and let that save the file; but
if there
is no local user with that name, we're still in
/etc/procmailrc
and can deal?

ok I figured that out - its a different procmailrc (because
a different user - unless that mail is for the user the
script is running as - then what ?  I could actually
ensure that never happens by structuring the
accounts and the remote mailbox and redirections
to avoid it but that doesn't feel like good safe
defensive programming (the worst will happen one day).

more comment below.

You don't really need sed, in any case.  In
procmail, try to
think procmail first and solve things natively if
possible.

For example, to find the local part of the address
in Delivered-To:

  :0
  * ^Delivered-To: \/[^(_at_)]*
  { LOCALNAME  $MATCH }

well not quite.  The local name is not the bit before the @.
There is a string before the @ that contains the local name
and I have to dump the other parts of it.  The ISP actually
gives multiple mailboxes and filters mails into them but
mangles the reipient address in this way when it does it.

I don't have the example to hand but its something like

plusz_axelrod-USERNAME(_at_)domain

and I have to extract the USERNAME value, hence
the sed.  Also I think the ISP puts multiple
addresses in there (after all from their p.o.v
it is delivered so they can do what they want with
that field).

All these mails from one mailbox are processed by one
user (so I can use pop3 to fetch instead of smtp)
and distributed to the multiple users (which are
actually list addresses - I'm wanting to shift some
mailman work onto this box).

So the trick below to avoid sed won't work either I think.

Thanks

andy


But even that is unnecessary, because the username
is already
known to procmail as $LOGNAME.


      :0
      * test -r /path/to/$LOGNAME/.procmailrc
      {
            DROPPRIVS  y
            SWITCHRC         # drop out of
/etc/procmailrc
      }


      # if we're still here, $LOGNAME had no
.procmailrc,
      # so save mesasge as root


      :0:
      save.$LOGNAME

--
dman

____________________________________________________________
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






____________________________________________________________________
eKit - the global phonecard with more!

Spend less on overseas calls, receive messages worldwide.
Visit http://www.ekit.com/ for details.


____________________________________________________________
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