Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Limiting recipients on a per-user basis

41 views
Skip to first unread message

ciapa_el_rat

unread,
Oct 19, 2005, 5:43:31 AM10/19/05
to
Hi,

I'm using sendmail 8.12.8-9.90 and I've a problem.
I need to limit on a per-user basis the number of recipients included in
a outgoing mail.
I've tried to set MaxRecipientsPerMessage parameter and it works,
unfortunately this setting limit *all* users.
Is there a way to do the same thing on a per-user basis?
Thank you in advance.

Ciapa

Robert Harker

unread,
Oct 19, 2005, 12:30:08 PM10/19/05
to
Humm.... Not really with any standard features of sendmail. But....

Here is a quick hack to the Local_check_mail and Local_check_rcpt
rulesets
to do just this.

The actual code (rules) are appended at the end of the message. You
would
put the file in ${CFDIR}/hack/maxrcpt.m4 and include it in your host.mc
file with:
HACK(maxrcpt)

You also need to include FEATURE(`access_db') before the HACK(maxrcpt)

The way this works is based on entries in the access database with the
prefix RMAX:

The format of the entry is:
RMAX:sender NumMaxRcpt

The sender can be a specific email address:
us...@example.com
Or a specific domain:
example.com
Or a default limit with dot:
.

The NumMaxRcpt is the maximum number of recipients this sender can mail
to
in a single message. A NumMaxRcpt of zero specifies no maximum number
of
recipients for this sender.

The order of limits is:
Default
Sender domain
Specific sender
This allows exceptions to be made for specific senders in a domain and
for specific domains from the default.

For example (order does not matter):
/etc/mail/access:
# A limit for a specific sender
RMAX:j...@blow.com 2

# No limit for a specific sender
RMAX:fl...@blow.com 0

# A limit for a specific domain
RMAX:blow.com 3

# No limit for a specific domain
RMAX:moe.com 0

# A default limit (for dot, like the mailer table)
RMAX:. 1

This would set:
A default maximum recipients of 1
Senders from the domain moe.com would have no maximum
recipients
Senders from the domain blow.com would have a maximum
recipients of 2
The sender j...@blow.com would have a maximum recipients of 3
The sender fl...@blow.com would have no maximum recipients

You would test this in address test mode by running the
Local_check_mail
ruleset with the sender to check the limit for.
You can check the set limit with:
${RMax}

Then you would run the Local_check_rcpt ruleset multiple times until
the
limit is reached. BTW, you can use the same recipient over and over,
it does not matter.

Now, if you would like more information on how rules and rulesets work,
how to write rules, and how to debug rulesets, as well as lot more
about how sendmail works and how to trouble shoot sendmail, please
look at our "Managing Internet Mail" class.

Hope this helps

RLH

> For info about our "Managing Internet Mail, Setting Up and Trouble <
> Shooting sendmail and DNS" and a schedule of dates and locations, <
> please send email to in...@harker.com, or visit www.harker.com <

Robert Harker Harker Systems
Sendmail and TCP/IP Network Training 4182 Plesant Hill Rd.
Sendmail, Network, and Sysadmin Consulting Lincoln, CA 95648
har...@harker.com 530-887-9990

### SNIP SNIP SNIP ###
hack/maxrcpt.m4:
divert(0)dnl
VERSIONID(`hack/maxrcpt.m4 Robert Harker 20051019')
VERSIONID(`Harker Systems, www.harker.com, 530-887-9990')

VERSIONID(`Limit the number of recipients a sender can send to')
VERSIONID(`with RMAX: prefix in the access database')

ifdef(`_ACCESS_TABLE_', `',
`errprint(`*** ERROR: HACK(`maxrcpt') requires
FEATURE(`access_db')
')')

LOCAL_CONFIG
# added by `HACK(maxrcpt)' with `LOCAL_CONFIG'

# macro storage map
Kmacro macro


LOCAL_RULESETS
# added by `HACK(maxrcpt)' with `LOCAL_RULESETS'

SLocal_check_mail
# initialize the RMax and RCurr macros
R $* $: $1 $(macro {RMax} $@ 0 $) $(macro {RCurr} $@
0 $)

# Put the address into the standard form
R $* $: $>CanonAddr $1 canonify sender
address

# Check for a default max recipients in a lookup focus
# Use empty default rewrite to indicate no max recipients found
R $+ <@ $+ . > $: < $(access RMAX:. $: $) > $1 <@ $2 . >

# Take the sender's domain and check for max recipients in a lookup
focus
R < $* > $+ <@ $+ . > $: < $(access RMAX:$3 $: $1 $) > $2 <@
$3 . >

# Take the sender address and check for max recipients in a lookup
focus
R < $* > $+ <@ $+ . > $: < $(access RMAX:$2@$3 $: $1 $) > $2
<@ $3 . >

# If the lookup focus is not empty, it contains this senders max
recipients
# Set RMax to this valuse
R < $+ > $+ <@ $+ . > $: $(macro {RMax} $@ $1 $) $2 <@ $3 . >

# Otherwise no max recipients was set, strip off the lookup focus,
# leaving the original focused address
R < > $+ <@ $+ . > $: $1 <@ $2 . >

SLocal_check_rcpt
# Does the sender have a max recipients, if zero exit ruleset
R $* $: < $&{RMax} >
R < 0 > $@ NoRMax for $&f

# Add one to the recipient count
R $* $: $(arith + $@ $&{RCurr} $@ 1 $)

# And store the value
R $+ $: $(macro {RCurr} $@ $1 $)

# Test if max recipients has been reached
R $* $: $(arith l $@ $&{RMax} $@ $&{RCurr} $)

# If true, reject the recipient
R TRUE $#error $@ 5.7.1 $: "550 Too many recipients for
sender" $&f

ciapa_el_rat

unread,
Oct 21, 2005, 4:55:53 AM10/21/05
to
Thank you very much.
I'll try
Ciapa
0 new messages