]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Rewrite from stelzi implemented, variable and function name renamed to match with...
[mailer.git] / inc / functions.php
index 7262baf0b705d1fad031146fbf42b482dcdac4dc..64e185bdec56a990499f7ae4018c482ea523da91 100644 (file)
@@ -1964,22 +1964,22 @@ function sendRawRequest ($host, $request) {
 }
 
 // Taken from www.php.net eregi() user comments
-function VALIDATE_EMAIL ($email) {
+function isEmailValid ($email) {
        // Compile email
        $email = COMPILE_CODE($email);
 
        // Check first part of email address
-       $first = "[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*";
+       $first = '[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*';
 
        //  Check domain
-       $domain = "[a-z0-9-]+(\.[a-z0-9-]{2,5})+";
+       $domain = '[a-z0-9-]+(\.[a-z0-9-]{2,5})+';
 
        // Generate pattern
-       $regex = '^'.$first.'@'.$domain.'$';
+       $regex = '@^' . $first . '\@' . $domain . '$@iU';
 
        // Return check result
-       // @TODO eregi() should be rewritten here
-       return eregi($regex, $email);
+       // @NOTE altered the regex-pattern and added modificator i (match both upper and lower case letters) and U (PCRE_UNGREEDY) to work with preg_match the same way as eregi
+       return preg_match($regex, $email);
 }
 
 // Function taken from user comments on www.php.net / function eregi()