On 13/05/12 17:24, Andrzej Adam Filip wrote:
> Mike Scott<usenet
...@scottsonline.org.uk.invalid> wrote:
>> On 10/05/12 23:32, Kees Theunissen wrote:
>>> Mike Scott wrote:
>>>> On 09/05/12 19:14, Kees Theunissen wrote:
>>>> ....
>>>>> My next suggestion would be to use some customized rewriting rules
>>>>> to accept certain patterns in unknown addresses. This has already
>>>>> been suggested by Andrzej Adam Filip.
>>>>> Depending on your pattern this can be done by simple rewriting
>>>>> rules (if the pattern fits properly in sendmail's rules to split
>>>>> an address in "tokens" and to test the tokens with $*, $- or $+) or
>>>>> you'll need a "regex map" to detect the pattern.
>>>>> Your current pattern requires a regex map.
>> ....
>> Ok, my final attempt :-)
>> in my .mc file:-
>> LOCAL_RULE_0
>> R$+.ln1<@$+> spam-rx<@$2>
>> should (and seems to) rewrite anything.ln1@somewhere to be
>> spam-rx@somewhere.
>> Seems to redirect matching addresses as needed, and without touching
>> any headers (which is a bonus). Have I missed anything please?
> 0) Limit your rule to local email domains only.
> R$+.ln1<@$=w> spam-rx<@$2>
Thanks - I'd actually caught that one before reading your post (slight
hiccup with TB and news being slow getting through :-( ).
What I currently have is
# read in aliases that always mean spam
F{spamrx} /etc/mail/spamrx
LOCAL_RULE_0
# Divert known spam recipient address to a common mailbox.
# match fixed stuff
R$={spamrx} < @ $=w . > $: spam-rx < @ $2 . >
# match stuf with variable part, special-cased
R$+.ln1 < @ $=w . > $: spam-rx < @ $2 . >
R$+.ntl.com < @ $=w . > $: spam-rx < @ $2 . >
which actually does seem to do the right things, rather to my surprise.
I know the $: isn't strictly needed.
> Test it with the command below:
> echo '3,0 x.ln1@localhost' | sendmail -bt -d21.12
..... then finally
parse returns: $# local $: spam-rx
while
echo '3,0 x.ln1@remotelhost' | sendmail -bt -d21.12
gives
...
parse returns: $# relay $@ XXXX . XXXX . co . uk $: x . ln1 <
@ remotelhost >
Ta muchly.
> 1) Do you want to get original envelope recipient addresses?
> [ YES => Are you ready to use procmail script in /etc/procmailrcs]
>> Incidentally, the Bat Book has a lovely 'question for the student'
>> concerning rules: "Is it possible to have text in the LHS that is
>> literally $+ , rather than an operator with the same characters?". I'm
>> dying to know the answer - can't find it anywhere! :-(
To answer my own question after a bit of trial and error, $$ seems to
mean a literal $. Weird it doesn't seem to be documented anywhere.
--
Mike Scott (unet2 <at> [deletethis] scottsonline.org.uk)
Harlow Essex England