sphinx Posted November 28, 2011 Share Posted November 28, 2011 Hello, I'm currently using this to block certain emails: $blacklisted = Array("[email protected]", "[email protected]", "[email protected]"); in with: if( !in_array( strtolower($email), $blacklisted ) ) { Ok, What I want to do, is be able to specify a domain extension such as '*@email.com' So anything with 'something'@email.com is blocked. I still wish to keep manual email address's in place aswell. Many thanks James Quote Link to comment https://forums.phpfreaks.com/topic/251990-block-email-extensions/ Share on other sites More sharing options...
MasterACE14 Posted November 28, 2011 Share Posted November 28, 2011 you can use strstr() to find the domain in the string. Quote Link to comment https://forums.phpfreaks.com/topic/251990-block-email-extensions/#findComment-1292003 Share on other sites More sharing options...
The Little Guy Posted November 29, 2011 Share Posted November 29, 2011 This worked for me: <?php $blacklistArr = array("[email protected]", "[email protected]", "[email protected]", "@gmail.com"); function isBL($e){ global $blacklistArr; $isBlackListed = false; foreach($blacklistArr as $email){ $email = preg_quote($email); if(preg_match("/$email/i", $e)){ $isBlackListed = true; break; } } return $isBlackListed; } $tests = array("[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]"); foreach($tests as $email){ echo "$email: "; var_dump(isBL($email)); echo "<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/251990-block-email-extensions/#findComment-1292054 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.