Quick email address check

This is a discussion on Quick email address check within the PHP General forums, part of the PHP Programming Forums category; I'm scripting a simple registry where the user can input their name and email address. I'd like to ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2008
Al
 
Posts: n/a
Default Quick email address check

I'm scripting a simple registry where the user can input their name and email address.

I'd like to do a quick validity check on the email address they just inputted. I can check the
syntax, etc. but want check if the address exists. I realize that servers can take a long time to
bounce etc. I'll just deal with this separately.

Is there a better way than simply sending a test email to see if it bounces?

Thanks....
Reply With Quote
  #2 (permalink)  
Old 03-26-2008
Eric Butera
 
Posts: n/a
Default Re: [PHP] Quick email address check

On Wed, Mar 26, 2008 at 1:28 PM, Al <news@ridersite.org> wrote:
> I'm scripting a simple registry where the user can input their name and email address.
>
> I'd like to do a quick validity check on the email address they just inputted. I can check the
> syntax, etc. but want check if the address exists. I realize that servers can take a long time to
> bounce etc. I'll just deal with this separately.
>
> Is there a better way than simply sending a test email to see if it bounces?
>
> Thanks....
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


You could use PEAR Validate::email() with the hostname lookup. It
isn't exactly what you're asking for but I use it a lot with fairly
good success.
Reply With Quote
  #3 (permalink)  
Old 03-26-2008
Richard Lynch
 
Posts: n/a
Default Re: [PHP] Quick email address check

On Wed, March 26, 2008 12:28 pm, Al wrote:
> Is there a better way than simply sending a test email to see if it
> bounces?


Yes.

Force the user to click on a link to prove that they actually CHECK
that email address.

Just because it doesn't bounce doesn't mean it's a valid email address.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

Reply With Quote
  #4 (permalink)  
Old 03-26-2008
Per Jessen
 
Posts: n/a
Default Re: [PHP] Quick email address check

Al wrote:

> I'm scripting a simple registry where the user can input their name
> and email address.
>
> I'd like to do a quick validity check on the email address they just
> inputted. I can check the syntax, etc. but want check if the address
> exists. I realize that servers can take a long time to bounce etc.
> I'll just deal with this separately.
> Is there a better way than simply sending a test email to see if it
> bounces?


Do an MX lookup on the domain, maybe attempt a brief connection to it.


/Per Jessen, Zürich

Reply With Quote
  #5 (permalink)  
Old 03-26-2008
Shawn McKenzie
 
Posts: n/a
Default Re: Quick email address check

Al wrote:
> I'm scripting a simple registry where the user can input their name and
> email address.
>
> I'd like to do a quick validity check on the email address they just
> inputted. I can check the syntax, etc. but want check if the address
> exists. I realize that servers can take a long time to bounce etc. I'll
> just deal with this separately.
>
> Is there a better way than simply sending a test email to see if it
> bounces?
>
> Thanks....


There may be a SMTP class to help you do it, or you can do it manually
but here is a quick process. Look up the MX for thedomain.com. maybe
use checkdnsrr(). If not found then it is bad, if found connect and
issue the following SMTP commands:

MAIL FROM: me@example.com
250 ok
RCPT TO: nonexistant@thedomain.com
550 sorry, no mailbox here by that name. (#5.7.17)

Optimally you want to see:
250 ok

You could also see:
553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)

This would mean that there is an MX record for thedomain.com pointing to
this server but this server isn't configured to accept mail for this domain.


-Shawn
Reply With Quote
  #6 (permalink)  
Old 03-26-2008
Al
 
Posts: n/a
Default Re: Quick email address check

All good suggestions guys. Richard's has the advantage of solving the potential for a delay by the
user's email server.

I'll have the user submit and tell'm to wait while I check the email address for them. Solves
several problems.

Al wrote:
> I'm scripting a simple registry where the user can input their name and
> email address.
>
> I'd like to do a quick validity check on the email address they just
> inputted. I can check the syntax, etc. but want check if the address
> exists. I realize that servers can take a long time to bounce etc. I'll
> just deal with this separately.
>
> Is there a better way than simply sending a test email to see if it
> bounces?
>
> Thanks....

Reply With Quote
  #7 (permalink)  
Old 03-27-2008
Manuel Lemos
 
Posts: n/a
Default Re: Quick email address check

Hello,

on 03/26/2008 02:28 PM Al said the following:
> I'm scripting a simple registry where the user can input their name and
> email address.
>
> I'd like to do a quick validity check on the email address they just
> inputted. I can check the syntax, etc. but want check if the address
> exists. I realize that servers can take a long time to bounce etc. I'll
> just deal with this separately.
>
> Is there a better way than simply sending a test email to see if it
> bounces?


You may want to try this E-mail validation PHP class that does just
that. It simulates an attempt to send a message to the SMTP server of
the e-mail domain. It does not finish to send the message. The message
could still bounce later, but at least you will still detect some
invalid addresses.

http://www.phpclasses.org/emailvalidation


--

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Reply With Quote
  #8 (permalink)  
Old 03-27-2008
Tom Chubb
 
Posts: n/a
Default Re: [PHP] Re: Quick email address check

Can anyone recommend anything that would be good to use on an existing
mailing list that is a few years old and didn't have any bounce handling?

On 27/03/2008, Manuel Lemos <mlemos@acm.org> wrote:
>
> Hello,
>
> on 03/26/2008 02:28 PM Al said the following:
> > I'm scripting a simple registry where the user can input their name and
> > email address.
> >
> > I'd like to do a quick validity check on the email address they just
> > inputted. I can check the syntax, etc. but want check if the address
> > exists. I realize that servers can take a long time to bounce etc. I'll
> > just deal with this separately.
> >
> > Is there a better way than simply sending a test email to see if it
> > bounces?

>
> You may want to try this E-mail validation PHP class that does just
> that. It simulates an attempt to send a message to the SMTP server of
> the e-mail domain. It does not finish to send the message. The message
> could still bounce later, but at least you will still detect some
> invalid addresses.
>
> http://www.phpclasses.org/emailvalidation
>
>
> --
>
> Regards,
> Manuel Lemos
>
> PHP professionals looking for PHP jobs
> http://www.phpclasses.org/professionals/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Reply With Quote
  #9 (permalink)  
Old 03-27-2008
Richard Heyes
 
Posts: n/a
Default Re: [PHP] Re: Quick email address check

> All good suggestions guys. Richard's has the advantage of solving the
> potential for a delay by the user's email server.
>
> I'll have the user submit and tell'm to wait while I check the email
> address for them. Solves several problems.
>
> Al wrote:
>> I'm scripting a simple registry where the user can input their name
>> and email address.
>>
>> I'd like to do a quick validity check on the email address they just
>> inputted. I can check the syntax, etc. but want check if the address
>> exists. I realize that servers can take a long time to bounce etc.
>> I'll just deal with this separately.
>>
>> Is there a better way than simply sending a test email to see if it
>> bounces?


The Mail/RFC822 class in PEAR has a quick(er) static method for checking
the format of an Interweb email address.

Mail_RFC822::isValidInetAddress()

IIRC

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
Reply With Quote
  #10 (permalink)  
Old 03-28-2008
Bill Guion
 
Posts: n/a
Default Re: Quick email address check

At 1:28 PM -0400 3/26/08, Al wrote:

>I'm scripting a simple registry where the user can input their name
>and email address.
>
>I'd like to do a quick validity check on the email address they just
>inputted. I can check the syntax, etc. but want check if the address
>exists. I realize that servers can take a long time to bounce etc.
>I'll just deal with this separately.
>
>Is there a better way than simply sending a test email to see if it bounces?
>
>Thanks....


I've had pretty good success from the following:

after checking the syntax (exactly one @, at least one . to the right
of the @, etc.), if it passes the syntax check, I then set $rhs to
everything to the right of the @. Then I test:

if (!checkdnsrr($rhs, 'MX'))
{
invalid
}
else
{
valid
}

-----===== Bill =====-----
--

You can't tell which way the train went by looking at the track.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:40 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0