procmail
[Top] [All Lists]

Re: Domain White Listing Question.

2004-06-10 00:48:56
Toen wij multimedia-fan(_at_)myrealbox(_dot_)com kietelden, kwam er dit uit:

# Now that we have the domain of the sender test it against a list of
#domains, domainwhitelist

:0
* FROM_DOMAIN ?? $FGREP -iqf $domainwhitelist
{
  LOG="Sender is from a whitelisted domain :$FROM_DOMAIN$NL"
  :0:
  FromWhitelistedDomain
}

If the number of whitelisted domains is not more than a few hundred, 
it can be done in 'just procmail'.

(1) If you make a file GOOD_DOMAINS.inc that looks like this:

  GOOD_DOMAINS = "
domain001.tld
domain002.tld
"

you can just test if FROM_DOMAIN is one of those domains

  :0
  * CLEANFROM ?? @\/.*
  { FROM_DOMAIN=$MATCH }
  
  INCLUDERC = GOOD_DOMAINS.inc
  :0
  *$ GOOD_DOMAINS ?? ^$\FROM_DOMAIN^
  {
    LOG = "Sender is from a whitelisted domain :$FROM_DOMAIN$NL"
    :0:
    FromWhitelistedDomain
  }


(2) Ideally you want to check if FROM_DOMAIN ends in one of the 
white-listed domains. For that you will have to reverse the 
GOOD_DOMAINS and the FROM_DOMAIN in the condition, but first
you need to change GOOD_DOMAINS.inc to something like this:

  GOOD_DOMAINS = "^^(\
([^.]+\.)*domain001\.tld|\
([^.]+\.)*domain002\.tld|\
@@)^^"  

That last @@ is just there to force you not to forget 
to end all the previous lines with |\

The condition then becomes:

  *$ FROM_DOMAIN ?? $GOOD_DOMAINS


(3) I use a sed-expression to transform a file that looks like 

#--------------------------------
# some comment
  @domain001.tld
  @([a-z0-9&_-]+.)*(_at_)domain002(_dot_)tld

# some other comment
  john(_at_)domain003(_dot_)tld
#--------------------------------

into a variable that contains such a regular expression.


(untesteted)

-- 
Grtz, Ruud

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>