At 13:48 2000-09-14 -0700, Widodo Krisman wrote:
I need procmail to read the TO address from a list of addresses
(myaddress.txt) and forward it to a list of forward addresses (forward.txt)
This seems like it'd be better implemented in sendmail - virtusertable.txt
all the 'myaddress.txt' to a single local username, and in aliases.txt,
specify the remote users to which mail to that username will forward. This
has the benefits of positively catching BCCs, etc.
I am reminded of something my father kept telling me about using the right
tool for the job...
Basically I want it to only forward mail sent to myaddress.txt and sent from
mydomain.com to the list of recipient in forward.txt.
Do I make any sense?
I have my .procmailrc as follow:
:0 c
* ^TO`cat /etc/myaddress.txt`
I've never tried this (ick!), but besides the performance (extra processing
overhead for each CHECK of your inbound mail, whether it matches or not),
you're going to run into trouble with the format in the myaddress.txt file
if it isn't a regexp. Further, this regexp should (unless I'm mistaken) be
preceeded by $ so that the results are expanded and then interpreted (but
as I've not tried doing this, I don't know that for sure - I use $ for
variable expansions).
>and in myaddress.txt I have something like (of course with a valid email):
me(_at_)testing(_dot_)com
anotherme(_at_)testing(_dot_)com
Just as I suspected. This won't match much of anything if used as a
regexp. You _might_ get what you're looking for if you format the file
like this:
(me(_at_)testing\(_dot_)com|anotherme(_at_)testing\(_dot_)com)
(yea, these example addresses could be optimized considerably - that's not
the point of this exercise though).
Other places which utilize the file could obviously be adversely affected.
in forward.txt I have something like:
(you would NOT format this file as the myaddress.txt above)
What am I missing? How come it's not forwarding? Any idea or suggestions?
This was covered about a month ago in detail under the subject heading of
"Forwarding to perl file list", though the fellow was having other problems
in addition, you should read that thread in it's entirety because your
filter could run into some of the same problems.
One problem which is clear is that your text file has addresses on separate
lines. The forward functionality doesn't expect them that way.
You should turn on verbose logging and fire messages at your recipe, then
check the results in the log. It's a useful discovery tool.
The final recipe from that thread, modified to what you're truing to do
(just removed an additional header tweak, which was part of what the other
person was doing - though you might want to use it too), the following
should accomplish what you're asking for:
:0fhw
* !^FROM_DAEMON
* !^X-Loop: myaddress(_at_)mydomain\(_dot_)com
* $^TO`cat /etc/myaddress.txt`
| formail -A"X-Loop: myaddress(_at_)mydomain(_dot_)com"
:0a
! `perl -pe 's/\n/ /g' < /etc/forward.txt`
This implements loop checking (you might not want the DAEMON check, though
removal presents other issues), and takes your address file and makes it
space-separated items on a single line. If you want to use cat like you
are at present, you'll need to manually change the address file from:
A
B
C
to:
A B C
You can also use sed or tn for transforming the multiline list to space
separated.
The address used in the X-Loop check, and the formail invocation which adds
it to the message, needen't correspond to the individual address which
matches in the TO -- it just should be unique to this recipe, or the host
account.
If the cat of the rewritten-as-regexp myaddress.txt file works, then
there's no reason you couldn't scrawl up a perl invocation to convert it
from its original format into a regexp.
Manually coding it into your .procmailrc of course WOULD work.
---
Please DO NOT carbon me on list replies. I'll get my copy from the list.
Sean B. Straw / Professional Software Engineering
Post Box 2395 / San Rafael, CA 94912-2395
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail