PHP Validation Options for Email Element

polarweb

Jeremiah
Hiya, got a strange request from a client wanting to have his email field not accept any email addresses from major providers such as gmail, hotmail, etc.

I am not a very good PHP guy, just learning the basics. Any suggestions on what we can put there as a validation to remove anything with @gmail, etc?
 
I guess the "regex" validation plugin should be a good candidate for this, but I am not very good with regular expressions. Searching the web for "ready made" expressions dealing with this should give you some examples.
 
hi, jfquestiaux
Could you tell me if you know how to validate the entered e-mail is alive or fake ? And is this possible on Fabrik ? I had been asked for my client but be not able to answer.
 
There is an "isemail" validation plugin (strangely enough, not part of the Fabrik core, you'll need to update from GitHub to get it) that checks the email syntax to see whether the data entered "looks like" an email, that is is like "something@domain.tld", with no forbidden character.
It does not tell you whether the entered address exists or not as there are no exact way of doing this, but it is a good start.
If you need more protection, you can add a CAPTCHA (there is a captcha element on GitHub).
 
Just to confirm a couple of points made in this thread.

There is no way of verifying if a given remote email exists or not. The original SMTP specification included a 'verify' command, but that was in the naive days of the 'net before spammers. Nobody implements 'verify' any more, as it's just a gift to spammers. Almost all SMTP servers will now just return "false" to a "VRFY" request. And a lot of them will add your IP to their tarpit list if you try a VRFY.

While the best way of weeding out given domains would be with a regex, as it happens, that's actually not a trivial regex to do as a single expression.

I'd recommend doing it as a PHP validation, which would be slightly easier to understand and maintain:

PHP:
$bad_domains = array('@gmail.com', '@hotmail.com');
foreach ($bad_domains as $bad_domain) {
   if (stristr($data, $bad_domain)) {
      return false;
   }
}
return true;

Doing it this way, it's clear and understandable, and all you need to do to add / remove domains from the list is edit that first line, to add or remove domains from the array.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top