Jump to content

Restrict Email Domains I.e. Gmail.com, Msn.com


Presto-X

Recommended Posts

Hello guys,

 

I'm trying to restrict free email providers domain's from our sign up form so they have to use their company's email address not their free spam email account. Below is the code I have written so far, it seems like it would work, and it seems to work most of the time, but from time to time one or two will slip in, how is that possible?

 

$domains = array('gmail','msn','yahoo','hotmail','excite','lycos','aol','inbox','fastmail','mail','maricopa','care2','zenbe','gmx','gawab','goowy','hotpop','mybestmail','bigstring','live','comcast','cableone','qwest','earthlink','netzero','clearwire','mybluedish','wildblue','clear');
$emailDomain = explode('@',$_POST['email']);
$emailDomain = explode('.',$emailDomain[1]);
if(in_array($emailDomain[0],$domains)){
 $error_msg = 'Sorry your email\'s domain is not allowed, please use your associated company email.';
}else{
 // Add the user to the database.
}

Link to comment
Share on other sites

I'm kind of with Jess here. Why is it in your interest to try and force potential customers to use a particular email address? There are lots of reasons why someone might want to use web email, and I know plenty of small companies, contractors and people who use these sites. I've worked with people who use aol as an example. So you basically don't want their business because they didn't use "someco.com". Seems short sighted to me.

 

With that said, your algorithm depends on explode, and exact matches. One obvious problem is that if I enter me@Gmail.com, i'm getting through your domain list.

 

Ditto, if I put in a subdomain like me@y.something.com.

 

I'd suggest at very least you do:

 

$_POST['email'] = strtolower(trim($_POST['email']));

Link to comment
Share on other sites

... users to use their real company email address.

 

You should try and convince him how dumb such a thing is. For some people those emails are their "real company email". I've seen numerous small-businesses that use whatever@comcast.net or whatever@gmail.com as their business email. Just a few weeks ago I was out and saw guy who runs a handyman/contracting business using hisname@comcast.net for his email. Had it painted on his truck right along side his business name, phone and fax numbers.

 

Link to comment
Share on other sites

So sitting here at an autoshop waiting for my car I see a bunch of business cards for different business in the area, bot big and small.

 

Remembering this thread I figured I would check the emails against the above. Results:

28 cards total

20 have a email on them

8 have an address that would be rejected by the above

 

Link to comment
Share on other sites

You should try and convince him how dumb such a thing is. For some people those emails are their "real company email". I've seen numerous small-businesses that use whatever@comcast.net or whatever@gmail.com as their business email. Just a few weeks ago I was out and saw guy who runs a handyman/contracting business using hisname@comcast.net for his email. Had it painted on his truck right along side his business name, phone and fax numbers.

 

I use gmail for my business/professional email account as well.

 

Not mentioned is how Sisyphean the task itself is. There are a gazillion free email services around the globe. Does your boss really think that it's possible to block all of them?

 

I mean, you could always just compare whether or not the email address' domain matches the domain of the website the user entered (if they're required to enter their business' URL (if they have one... oy)), but then you're back at "This is a dumb idea" anyway.

 

:facepalm:

 

Can you show your boss this thread? Because he strikes me as one of those people who's more apt to listen to professional strangers on the internet than the people he hired expressly for their technical ability. Not kidding. There are plenty of middle management people who can only be persuaded that their idea is shit by a neutral and respected 3rd party.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.