I can see that my rule was called 4 times.
Sep 26 18:32:57 apache sendmail[28918]: m8QCWfUk028918:
syslog:LR0:0:smorrison<@aps1.net.>
Sep 26 18:32:57 apache sendmail[28918]: m8QCWfUk028918:
syslog:LR0:0:paradise<@anrb.ru.>
Sep 26 18:33:18 apache sendmail[28918]: m8QCWfUk028918:
from=<smor...@aps1.net>, size=4205, class=0, nrcpts=1,
msgid=<000901c91fd5$06ea09ef$030c4180@qbsnu>, proto=ESMTP, daemon=MTA,
relay=[93.127.33.26]
Sep 26 18:33:18 apache sendmail[29383]: m8QCWfUk028918:
syslog:LR0:0:smorrison<@aps1.net.>
Sep 26 18:33:18 apache sendmail[29383]: m8QCWfUk028918:
syslog:LR0:0:paradise<@anrb.ru.>
Sep 26 18:33:19 apache sendmail[29383]: m8QCWfUk028918:
to=<para...@anrb.ru>, delay=00:00:22, xdelay=00:00:01,
mailer=smtp, pri=124205, relay=mail.anrb.ru. [212.193.134.2],
dsn=2.0.0, stat=Sent (m8QCtfSn019896 Message accepted for delivery)
The first output is sender and the second output is recipient.
But after "from=" these records repeat themselves.
Id est LOCAL_RULE_0 rules are being executed twice firstly and twice
after.
Does it mean that any action in the LOCAL_RULE_0 will be executed 4
times?
For example, I make dnsbl-check in the LOCAL_RULE_0 to redirect spam
to some local user.
Do 4 identical dnsbl lookups happen for one mail?
> I have added this rule in my sendmail.mc
> LOCAL_RULE_0
> R$* $: $(syslog syslog:LR0:0: $1 $) $1
>
> I can see that my rule was called 4 times.
Use the modification below to see the difference between the calls:
LOCAL_RULE_0
R$* $: $(syslog syslog:LR0:0:&${addr_type}: $1 $) $1
e s => enveloper sender
e r => envelope recipient
h => header recipient address or header sender address
> [...]
> Does it mean that any action in the LOCAL_RULE_0 will be executed 4
> times?
Or more :-) [multiple enveloper recipients, multiple addresses in headers]
> For example, I make dnsbl-check in the LOCAL_RULE_0 to redirect spam
> to some local user.
Limit the redirecting code only to situation where &${addr_type} is
equal "e r".
> Do 4 identical dnsbl lookups happen for one mail?
--
[pl>en Andrew] Andrzej Adam Filip : an...@onet.eu : an...@xl.wp.pl
Ask not what's inside your head, but what your head's inside of.
-- J. J. Gibson
1. Thank you very much for this tip. I failed to take it into account.
But now I get dnsbl-check twice.
The first check is doing before string "from=" and the second check is
doing after "from="
I added $&{DeliveryMode} and noticed that it's value equals "b" in
the first case and "i" in the second case:
Sep 27 18:43:46 apache sendmail[23513]: m8RChhGE023513: syslog:
01:jjkhhandyandy<@halifax.com.hk.>\233<e.s>\233<b>
Sep 27 18:43:46 apache sendmail[23513]: m8RChhGE023513: syslog:
01:paradise<@anrb.ru.>\233<e.r>\233<b>
Sep 27 18:43:47 apache sendmail[23513]: m8RChhGE023513:
from=<jjkhha...@halifax.com.hk>, size=650, class=0,
nrcpts=1,msgid=<000401c920a0$0703c717$78d91499@cubfskjp>, proto=ESMTP,
daemon=MTA,
relay=pool-72-87-102-181.prvdri.east.verizon.net[72.87.102.181]
Sep 27 18:43:47 apache sendmail[23536]: m8RChhGE023513: syslog:
01:jjkhhandyandy<@halifax.com.hk.>\233<e.s>\233<i>
Sep 27 18:43:47 apache sendmail[23536]: m8RChhGE023513: syslog:
01:paradise<@anrb.ru.>\233<e.r>\233<i>
Sep 27 18:43:47 apache sendmail[23536]: m8RChhGE023513:
to=<para...@anrb.ru>, delay=00:00:01, delay=00:00:00,
mailer=local, pri=120650, dsn=2.0.0, stat=Sent
So to get only one dnsbl-check I use the following now:
R$* $: $1 $| <$&{addr_type}> $| <$&{deliveryMode}>
R$* $| <e r> $| <i> $: $1 $| $>Dnsbl_Check
R$* $| <$*> $| <$*> $: $1
Is it correct to use <$&{deliveryMode}> at this point ?
> > Does it mean that any action in the LOCAL_RULE_0 will be executed 4
> > times?
>
> Or more :-) [multiple enveloper recipients, multiple addresses in headers]
>
> > For example, I make dnsbl-check in the LOCAL_RULE_0 to redirect spam
> > to some local user.
>
> Limit the redirecting code only to situation where &${addr_type} is
> equal "e r".
2. The second question is about multiple recipients.
As you said in that case LOCAL_RULE_0 will be executed several times
so I shall get several dnsbl-lookups.
To prevent this I tryed to use "e s" instead of "e r" but without
success.
I add new macros to save result of dnsbl-lookup and for second,
third,etc recipients I check only $&{Spamcop_lookup}
D{Spamcop_lookup}0
R$* $: $&{Spamcop_lookup}
R0 $: 0 $| $&{client_addr}
R0 $| $-.$-.$-.$- $: 0 $| <$(dnsbl $4.$3.$2.$1.bl.spamcop.net.
$: OK $)>
R0 $| $* $: $(storage {Spamcop_lookup} $@ $1 $) $1
It works and now I get only one dnsbl-lookup.
But may be there is more correct way to do it?
I would suggest you to
a) ignore delivery mode.
b) check $&{opMode} to be sure the rule will not be called during
rebuilding of alias database
If you are concerned about performance then you may store "per message"
result of dnsbl lookups in queue file. Use macro map to set value of
macro.
>> > Does it mean that any action in the LOCAL_RULE_0 will be executed 4
>> > times?
>>
>> Or more :-) [multiple enveloper recipients, multiple addresses in headers]
>>
>> > For example, I make dnsbl-check in the LOCAL_RULE_0 to redirect spam
>> > to some local user.
>>
>> Limit the redirecting code only to situation where &${addr_type} is
>> equal "e r".
>
> 2. The second question is about multiple recipients.
> As you said in that case LOCAL_RULE_0 will be executed several times
> so I shall get several dnsbl-lookups.
> To prevent this I tryed to use "e s" instead of "e r" but without
> success.
> I add new macros to save result of dnsbl-lookup and for second,
> third,etc recipients I check only $&{Spamcop_lookup}
> D{Spamcop_lookup}0
> R$* $: $&{Spamcop_lookup}
> R0 $: 0 $| $&{client_addr}
> R0 $| $-.$-.$-.$- $: 0 $| <$(dnsbl $4.$3.$2.$1.bl.spamcop.net. $: OK $)>
> R0 $| $* $: $(storage {Spamcop_lookup} $@ $1 $) $1
>
> It works and now I get only one dnsbl-lookup.
> But may be there is more correct way to do it?
I think it is the right path to search for best solution for your problem.
--
[pl>en Andrew] Andrzej Adam Filip : an...@onet.eu : an...@xl.wp.pl
...there can be no public or private virtue unless the foundation of action is
the practice of truth.
-- George Jacob Holyoake