|
Posted by Tim Roberts on 06/12/06 07:33
Nick Bell <me@privacy.net> wrote:
>The expression:
>
>preg_match_all("/text.*?([A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6})/i",$f,
>$matches);
>
>Returns ONE email address on a line in $f beginning 'text' - how do I
>retrieve ALL the email addresses on a line in $f beginning 'text' in php?
This isn't foolproof by a long shot. Every printable character except [,
\, and ] is valid in an RFC2822 e-mail address, and even [ and ] can be
used if the address is wrapped in quotes.
The full regular expression required to match an RFC2822 compliant e-mail
address is more than 6,000 characters long, and is one of the gems in
Friedl's book "Mastering Regular Expressions".
It is common to use "*" in an e-mail address, for example. Sendmail has a
feature that uses it. If you send to "abc*def@joe.com", it will try find
an alias for "abc*def" exactly. Failing that, it will send the message to
"abc@joe.com". This is great for spam catching; I can sign up with web
sites as "timr*121@probo.com" without defining it, and if I get to much
spam, I just add a specific alias for that which routes to null.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Navigation:
[Reply to this message]
|