p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 (http://p2p.wrox.com/forumdisplay.php?f=33)
-   -   Validate Email address (http://p2p.wrox.com/showthread.php?t=19134)

richardtr September 29th, 2004 03:29 AM

Validate Email address

I want to validate that an email address is not syntactically coreect (i.e. xxxxx @ yyyy . zzzz) but to prove that the address exists.

Is there any way to do this ?


richard t-r

bmains September 29th, 2004 09:51 AM

Use regular expressions. But do you mean search to see if an email address is taken by an actual person?

richardtr September 29th, 2004 10:09 AM

Exactly, to see if the email address exists,
or at least the domain i.e. the bit after the @ e.g. tdoc.net.


richard.york September 29th, 2004 10:18 AM

There is no way to verify the email address without user action. You can ping the domain and make sure the domain exists, but beyond that you'd have to send the user an email with a verification code or something like that to verify the address itself.


[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail

bmains September 29th, 2004 02:24 PM

Yes, domains don't have accessible lookups online.

Brian5517 November 23rd, 2004 01:33 PM

I was wondering if there is a way to check for spaces inside an email address?

richard.york November 23rd, 2004 01:45 PM

> I was wondering if there is a way to check for spaces inside an email address?

There are several ways of validating an email address (from a syntactical standpoint).

I've used something like this in the past, and it works pretty well.


function is_email($email)
    return ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$", $email);

If you just want to check for the presence of space, do something like the following:

if (strstr(trim($email), ' '))
    // The email contains single space characters
    // The email does not contain space characters

(This doesn't find tabs BTW)



Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design

All times are GMT -4. The time now is 06:23 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.