On Wed, 3 Jul 2002, Werner Reisberger wrote:
I am looking for a regexp usable in a procmail recipe which checks if
an email address is valid according to rfc822.
I've had something for this sitting around for a while, so I tossed it up
on the web:
It's essentially a translation of the RFC822 address grammer into a regex,
broken up as variables for readability.
Doesn't include the recursive INCLUDERC that would be necessary to strip
out parenthesized comments, though.
One exception of rfc822 could be that the local-part is not composed of
characters within double quotes. I also don't want to allow a domain
part consisting of an IP address.
In the above, to exclude quoted strings, change the definition of the
$word__ variable; to exclude domain literals, change $subdomain__. It
should be pretty obvious what changes to make.
Then you'd use something like
* $ subscraddr ?? $mailbox__
* $ subscraddr ?? $addrspec__
(The double trailing underscores are to lessen the chance of collision
with somebody else's variable names.)
procmail mailing list