Please tell me which expression should be correct?

I am trying to use / /^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/ , but it does not work.

2 answers 2

using this: PhP Filter var

 filter_var('bob@example.com', FILTER_VALIDATE_EMAIL); 
  • I don’t know for Chinese, but with Russian letters of norms) - Evgeniy Mikhalichenko 2:38 pm
  • @EvgeniyMikhalichenko, filter_var('wordpress@имя-сайта.рф', FILTER_VALIDATE_EMAIL) -> false or are you not talking about these Russian letters? - Visman
  • The function only works for Latin. The mail address in the national language will not pass verification. - Alex

You can’t determine whether you have entered a real address or not.

It is enough to check the presence of dogs in the line

 if (strpos($email, '@') > 0) { // отправляем проверочное письмо } 

and then send an email to this address to confirm it.

And only after confirmation from the letter you will receive 100% confidence that at the moment this address is real.

UPD VerifyEmail checks the reality of email through 1. the presence of MX records for the domain specified in the email and if it (s) is (t), then 2. check the presence of the mailbox through communication with this mail server using the smtp protocol.

  • one
    Not quite right. The user could trite obscure, so you need to prompt an input error. And the reality of the address is verified by the confirmation of the sent letter. If sending happens at all :) - user207618
  • there will always be a point after n characters after @ - Alex
  • one
    @Other, yep, how can the regular user tell the user that instead of the letter k accidentally pressed l : P - Visman
  • But from @mail can save. - user207618 2:26 pm