Possible duplicate:
Verify Javascript email address?
I know that there is no way to verify the email address using only regular expression, but I think I should be able to reject some obviously invalid ones to help friendly users who mistakenly entered something else, for example their name or password in the address field Email. Therefore, I do not want to reject valid email addresses, but would like to reject as many invalid email formats as possible using only regular expression. But I think any javascript / jquery / ... will be fine too.
Here is what I still have:
^ .+@. +\..+$
Yes, there is no regex for a real check, but there must be something to reject. No, this does not stop anyone from entering fake addresses. Yes, you should still send a confirmation email to confirm.
The above regex will be used from javascript.
-
In .NET, I would instead allow .NET to check the email format using
try { var mailAddress = new MailAddress(possibleMailAddress); }
and if everything is ok, check the DNS records for part of the domain to see if there can be a mail server. Only if the DNS records clearly indicate that there can be no mail server or no such domain, the email address is rejected. Then cache some of the results to speed up your search in the future.
However, I must send confirmation letters to verify ...
source share