RE: [PHP] checking if e-mail address and syntax are valid

From: Date: Tue, 24 Apr 2001 20:39:28 +0000
Subject: RE: [PHP] checking if e-mail address and syntax are valid
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50165@lists.php.net to get a copy of this message
I'd like to add to that, before someone spends a lifetime searching for an answer ... "Solution: There isn't one. You cannot do real-time validation of mail addresses. You must pick from a number of compromises." The section goes on describing how many RFC-valid addresses are undeliverable and on the opposite side of the coin, some RFC-invalid addresses are perfectly deliverable. "Our best advice for verifying a person's mail address is to have them enter their address twice, just as you would when changing a password." - Chris > > I would like to know if anyone has or know any PHP code to verify if a > > form entered e-mail address is valid? > > > > I would like that things like 4$%^%$@@.com.br could not be sent. I only > > has to verify the syntax of it, the existance I believe should be harder > > to verify but if it is possible I would be glad if anyone could point me > > the way. > > This is taken from PHP Developers Cookbook. Don't ask me exactly what it > does, because I don't know. I think I can grasp the basics of it though. > It isn't fool proof tho. > > > if (!eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$", > $users)) die ("Invalid email");

« previous php.general (#50165) next »