How exactly do i validate the domain part of an email address? Do i need to first list out the existing domains in my java class or java's InternetAddress.validate() will perform it by default? I have used this:
public static boolean verifyEmailAddress(String regEmail) {
boolean result = true;
try {
InternetAddress emailAddr = new InternetAddress(regEmail);
emailAddr.validate();
} catch (AddressException ex) {
result = false;
}
return result;
}
The request.getParameter has an email address and stored in regEmail..
The problem is even for invalid emails like [email protected] its showing valid.. What exactly do i need to do.. Help me out.. And also is this function working fine to those who have used it and tested ?
I think you are approaching the problem from the wrong perspective. From your application point of view, an email should be considered valid (better, useful) if it can receive mail. That's why all those forums keep sending you activation email :) You should send some random string to every new email address and keep it in a quarantine state until the user can prove he read the secret.
This is because the domain could exist, or even an MX record for that domain can exist in DNS, but neither of these conditions can guarantee that the address is valid - again, when you validate something you are really stating that it can be used later in your code for some purpose, and the purpose for an email address is to receive mail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With