Validate emails from a specific domain

0

How could you validate that the registered email has a specific domain, eg

[email protected]         válido
[email protected]        válido
[email protected]      no válido

What I want is to validate that all emails that are registered have mandatory @ mydomain.com, I tried it with regular expressions but the problem was that it allowed the letters that @mydomain use could be used in any order by

[email protected]  lo valida

is to use it, in which the user who registers has the mail of the company.

Greetings.

I'm working with PHP, I'm not using any framework, FILTER_VALIDATE_EMAIL does not work for me in that case.

Another detail that I miss the domain is local [email protected]

    
asked by Edy Lasso 20.06.2017 в 16:42
source

1 answer

0
$str = '[email protected]';
if( preg_match('/^([a-z0-9_\.-]+)@midominio\.com$/', $str) )
  echo 'Válido';
else
  echo 'Inválido';
    
answered by 20.06.2017 / 16:56
source