Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if email are valid and exists

I am working on a web app that requires me to check if the users email are valid and exists. (I do the regex check) The question is what is best practice of verifying that an email exists?

Here are some options that I have though about:

  1. send an email to the user and make them confirm the email address
  2. do a VRFY SMTP - is this still used? should i bother looking into it?
  3. any other good idea?
like image 260
Murre Avatar asked Nov 28 '22 12:11

Murre


2 Answers

sending a verification email to the user verifies that the email is valid and that the user is the owner of the account

like image 162
knoopx Avatar answered Dec 04 '22 13:12

knoopx


Doing a regex check on an email address can be frustrating for some users, depending upon the regex. In my case, I have several domains where all of the addresses are delivered to a single mailbox, so I can use the address to specify the sender (for filtering). Here are some valid (per RFC 2822) address patterns that I have had rejected by various websites:

[email protected]
[email protected]
[email protected]
[email protected]

I recommend that you skip your regex test and just send the verification email with a confirmation link -- anything else will leave your application brittle and subject to breakage as soon as someone comes up with a new DNS or SMTP extension.

PS: ICANN is expected to approve UNICODE domain names Real Soon Now. That will play merry hell with Regex patterns for email addresses.

like image 28
Craig Trader Avatar answered Dec 04 '22 14:12

Craig Trader