How-to restrict certain domains

Julian Field mailscanner at ecs.soton.ac.uk
Fri Jan 16 16:52:26 GMT 2004


At 16:34 16/01/2004, you wrote:
>So I take it this is not possible?

There are limits to what the rulesets can do. However you could do it very 
easily with a Custom Function. You just need to look at 
$message->{fromdomain} and @{$message->{todomain}} and see if either 
contains aol.com.

Tie that Custom Function into "Non Spam Actions" and you're away.
The Perl to do this is dead simple, take a look at the start of 
CustomConfig.pm for examples.
You  might find the result looks almost exactly like this (bung this in 
CustomConfig.pm somewhere near the top)
-----------SNIP------------
my $NoAOLDomain = 'cant-talk-to-AOL.com';

sub InitAOLCheck {
   # No initialisation needs doing here at all.
   MailScanner::Log::InfoLog("Initialising AOLCheck for $NoAOLDomain");
}

sub EndAOLCheck {
   # No shutdown code needed here at all.
   # This function could log total stats, close databases, etc.
   MailScanner::Log::InfoLog("Ending AOLCheck");
}

# This will return 1 for all messages except those generated by this
# computer.
sub AOLCheck {
   my($message) = @_;

   return "deliver" unless $message; # Default if no message passed in

   # Is it to or from AOL?
   my($InvolvesNoAOLDomain, $InvolvesAOL, $domain);
   $InvolvesNoAOLDomain = 0;
   $InvolvesAOL = 0;
   foreach $domain ($message->{fromdomain}, @{$message->{todomain}}) {
     $InvolvesAOL = 1 if $domain =~ /aol\.com$/i; # Does it end in aol.com?
     $InvolvesNoAOLDomain = 1 if $domain =~ /$NoAOLDomain$/io;
   }

   # Bounce the message if it involved our non-AOL-domain and AOL
   return "bounce" if $InvolvesAOL && $InvolvesNoAOLDomain;
   # Otherwise deliver it
   return "deliver";
}
-----------SNIP------------

Then set in MailScanner.conf:

Non Spam Actions = &AOLCheck

and restart MailScanner. First time set "Debug = yes" so you can see any 
Perl syntax errors I have made.

Have a good weekend!

>-----Original Message-----
>From: MailScanner mailing list [mailto:MAILSCANNER at JISCMAIL.AC.UK] On Behalf
>Of Mike Kercher
>Sent: Thursday, January 15, 2004 11:27 PM
>To: MAILSCANNER at JISCMAIL.AC.UK
>Subject: Re: How-to restrict certain domains
>
>I don't think that tutorial quite covers what he wants to do.
>
>Seems he'd need a ruleset like this:
>
>Non Spam Actions = /etc/MailScanner/rules/noaol.rules
>
>FromTo:         *@mydomain.com  FromTo:*@aol.com                bounce
>FromTo: default deliver
>
>To my knowledge, such a ruleset is not possible (yet)
>
>Am I thinking wrong?
>
>Mike
>
>
>-----Original Message-----
>From: MailScanner mailing list [mailto:MAILSCANNER at JISCMAIL.AC.UK] On Behalf
>Of Ugo Bellavance
>Sent: Thursday, January 15, 2004 9:43 PM
>To: MAILSCANNER at JISCMAIL.AC.UK
>Subject: Re: How-to restrict certain domains
>
>
>
>         -----Message d'origine-----
>         De : Sanjay K. Patel [mailto:sanjay.patel at REXWIRE.COM]
>         Envoyé : Thursday, January 15, 2004 10:41 PM
>         À : MAILSCANNER at JISCMAIL.AC.UK
>         Objet : How-to restrict certain domains
>
>
>
>         We host mail for 5 domains. But we want to restrict one domain from
>receiving or sending mail aol.com.
>
>         How can we do this with MailScanner.
>
>         SKP
>         [Ugo Bellavance]
>
>         See the ruleset tutorial :
>http://www.sng.ecs.soton.ac.uk/mailscanner/serve/cache/230.html

-- 
Julian Field
www.MailScanner.info
MailScanner thanks transtec Computers for their support

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654




More information about the MailScanner mailing list