At 09:50 2005-06-28 -0700, Bart Schaefer wrote:
[snip]
Good idea.
ALIAS=$1
:0
* ALIAS ?? aliasname
! aliasaddress(_at_)otherdomain(_dot_)com
:0
* ALIAS ?? othername
! otheraddress(_at_)thirddomain(_dot_)com
(One recipe block for each possible value of ALIAS.)
Er, might be easier to maintain by performing a lookup using grep:
# note that as written, this retains case sensitivity - though EMAIL isn't, so
# you might want to chuck '-i' in there. the filename is non-special, just
# made up to make sense for what it is used for:
FWDADDR=`grep "^$ALIAS:" /etc/mail/procmail-aliases.txt`
# arguably, you could check to see if the first character of the forward
# address is a pipe or a colon and simulate a piped or file delivery as
# appropriate instead, but if you're planning to stick to
:0
* FWDADDR ?? ^[^:]*:[ ]*\/[^ ]*
{
# this should match something so long as the alias was legit.
# we should now have a FWDADDR which is the RHS of the forward
# component. Note that CONTINUED lines aren't supported.
FWDADDR=$MATCH
:0
! $FWDADDR
}
# Either there was no match on the grep, or there's something wrong with
# the alias definition, and therefore, we ended up here.
# do something, such as store, and (unwritten here) send a notice to the
# admin that they fscked up and didn't maintain the the procmail-aliases file
:0:
/path/to/fscked.$ALIAS
Keep in mind that this sort of forwarding will CHANGE the envelope
sender. As such, you may want to extract the envelope sender and re-set it
on the message when forwarding it.
By maintaining the aliases in a procmail-aliases file (with basically the
same syntax as a regular aliases file), maintenance is significantly less
of a hassle. One could write a simple db lookup tool and then the
procmail-aliases file could be managed by makemap (the db construction tool
that is part of sendmail), which would handily deal with parsing issues and
line continuations.
---
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