[Mimedefang] many recipients

Matthew.van.Eerde at hbinc.com Matthew.van.Eerde at hbinc.com
Thu Sep 2 12:43:20 EDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

CONTRERAS, Pablo wrote:
> Hi, I test this and work ok!, my server run with relay of internet
> what can I do for apply this filter only with address external
> I try to make this but doesn't work
> I try this
> sub filter_begin {
> 	# Why doesn't work this "if"
> 	if ($RelayAddr ne "192.198.100.10"){
>        	 #  reject email with too many recipients
>          	if (@Recipients > 5) {
>            	return action_bounce("Too many recipients,
> message refused")
>          	}
>        }
> }

@Recipients is always () in filter_begin - so @Recipients > 0 is always
false.

What are you trying to do?  If more than five people at your domain are
RCPT'd TO on the message, to reject the whole message for everybody? 
In that case put it in filter_end.

Or are you trying to restrict the sending server to five RCPT TO's per
MAIL FROM?  something like

MAIL FROM: from at example.com
> 2xx OK
RCPT TO: 1 at example.org
> 2xx OK
RCPT TO: 2 at example.org
> 2xx OK
RCPT TO: 3 at example.org
> 2xx OK
RCPT TO: 4 at example.org
> 2xx OK
RCPT TO: 5 at example.org
> 2xx OK
RCPT TO: 6 at example.org
> 4xx too many recipients give me the data and do a RSET

This is the effect of the confMAX_RCPTS_PER_MESSAGE in sendmail's .mc
files.

Or do you want to count every email address the To: and CC: headers,
regardless of whether they're at your domain?  That would need to go in
filter_end.  @Recipients wouldn't be what you'd want there... unless
you wanted to count BCC's in your domain (you can never find out about
BCC's in other domains.)

Somehow you'd have to read the value of the To and CC headers in
filter_end - pseudocode follows:

filter_end
{ ...
my %totalrecipients = ();
my $toandccheaders = "";

open(HEADERS, "./HEADERS") or die ...;
my @lines = <HEADERS>;
close(HEADERS);

for my $line (@lines)
{	next unless $line /^(To|Cc):\s*(.+)/i;
	$toandccheaders .= $2 . " "; 
}

for my $email (split /some kind of regexp/, $toandccheaders)
{	$totalrecipients{lc $email}++;
}

for my $email (@Recipients) # include BCC recipients at our domain
{	$totalrecipients{lc $email}++;
}

if (keys %totalRecipients > 5)
{	action_bounce("too many recipients!");
}
...
}

Matthew.van.Eerde at hbinc.com                      805.964.4554 x902
Hispanic Business Inc./HireDiversity.com         Software Engineer
perl -e"map{y/a-z/l-za-k/;print}shift" "Jjhi pcdiwtg Ptga wprztg,"
-----BEGIN PGP SIGNATURE-----
Comment: pub key http://matthew.vaneerde.com/pgp-public-key.asc

iD8DBQFBN02lUQQr0VWaglwRAh3qAJ9tK+Y+4OYy4WPQqMEmTk57a7Yb/gCfXmXG
CuPTn66geqz7rofUnhnr/Os=
=FbRY
-----END PGP SIGNATURE-----



More information about the MIMEDefang mailing list