Validate entry to white/black lists

Marina Brown marina at SURFERZ.NET
Tue Mar 16 21:25:17 GMT 2004


go to CPAN - there are some mail-verifying modules already written.

Marina Brown


On Tuesday 16 March 2004 03:18 pm, you wrote:
> Hi,
>
> I'm new to regex and am trying to put together some code that will
> validate an email address or domain before entry into the black and
> white lists. I have a system setup in which you forward a spam message
> to blacklist at mydomain.com and the script parses the spam email address
> and adds it to the blacklist. Well I'm still debugging the script, but
> regardless, I'd like to setup a validation process before the email
> address is actually written to the blacklist. Because if an invalid
> entry gets written, email stops getting processed and errors are written
> to the log.
>
> I've put together the following based on searches through deja, but it
> does not account for subdomains. And really, I don't care about
> validating the actual characters, like the script does, just validating
> that the entry will not break MailScanner with spaces, etc.
>
> This is the regex so far:
>
> if ( $email =~ /^[a-zA-Z][\w\-\.\&]{3,}\@\w[\w-]*\.\w+$/ or $email =~
> /^@\w[\w-]*\.\w+$/ or $email =~ /^\*@\w[\w-]*\.\w+$/) then email is
> valid...
>
> I'm looking to allow:
>
> xxxx at xxx.xxx
> xxxx at xxx.xxx.xx
> xxxx at xxx.xxx.xx.xx (not sure how many subs are valid)
> @xxx.xxx
> @xxx.xxx.xx
> @xxx.xxx.xx.xx
> *@xxx.xxx
> *@xxx.xxx.xx
> *@xxx.xxx.xx.xx
>
> Can anyone help, or is there a better approach I should take?
>
> Thanks,
> Max




More information about the MailScanner mailing list