[imp] IMP 2.3 address books

Rich Lafferty rich@horde.org
Tue, 9 Oct 2001 13:08:14 -0400


On Mon, Oct 08, 2001 at 12:35:13PM -0600, Lic. Rodolfo Gonzalez Gonzalez (rodolfo@equinoxe.g-networks.net) wrote:
> 
> I'm attaching a PHP class by Manuel Lemos which does it.

...Poorly. You can't match an email address with a regular expression
with a standard regular expression, as email addresses can contain
nested comments. (The full RFC822 address spec, but without nested
comments, translates into a regular expression of about 70 lines.)

>  var $email_regular_expression="^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$";

I don't think this person read the RFC; he's omitted lots of valid
characters. Eli the Bearded <*@qz.to> would be disappointed, as would
anyone using sendmail, exim or postfix's plus-addressing feature that
allows mail sent to <user+arbitrary-string@host> to be directed to
<user@host>.

This:

>     && $this->PutLine($connection,"HELO $localhost")
>     && $this->VerifyResultLines($connection,"250")>0
>     && $this->PutLine($connection,"MAIL FROM: <$localuser@$localhost>")
>     && $this->VerifyResultLines($connection,"250")>0
>     && $this->PutLine($connection,"RCPT TO: <$email>")
>     && ($result=$this->VerifyResultLines($connection,"250"))>=0)

fails on mail exchangers. The machine receiving mail for a domain
isn't necessarily going to know about which users are valid; it might
leave it up to the host to which it relays to actually bounce. Even
then, some mailers, such as Exim, accept all mail in their default
configuration and then send a bounce, rather than not accepting it at
SMTP time. 

The only way to verify that an email address exists is to send mail to
it requiring a non-automated response.

  -Rich

-- 
Rich Lafferty --------------+-----------------------------------------------
 Ottawa, Ontario, Canada    |  Save the Pacific Northwest Tree Octopus!
 http://www.lafferty.ca/    |    http://zapatopi.net/treeoctopus.html
rich@lafferty.ca -----------+-----------------------------------------------