[Mimedefang] Matching question

David F. Skoll dfs at roaringpenguin.com
Mon Feb 25 18:43:43 EST 2002


On Mon, 25 Feb 2002, Ashley M. Kirchner wrote:

>     if ($Sender =~ /newsletter\.online\.com/) {

Be careful; $Sender sometimes has angle-brackets.

I recommend something like this:

	my($RawSender);
	$RawSender = $Sender;

	# Strip angle brackets
	$RawSender =~ s/[<>]//g;

	# Match domain
	if ($RawSender =~ /\@newsletter\.online\.com$/) {
		$HTMLOK = 1;
	} else {
		$HTMLOK = 0;
	}

The match is a little tighter, matching the "@" and insisting that ".com"
is the end of the string.

However, you'll quickly go crazy maintaining things like this.  You might
want to extract the domain part (everything after "@") and look it
up in a DBM hash.  You can maintain a list of allowed domains and
use tie() to tie an array to the DBM hash.

Regards,

David.




More information about the MIMEDefang mailing list