how to check that the email id exist in domain without sending any mails using java

一笑奈何 提交于 2019-12-30 04:46:26

问题


Is there any way to verify where the email id exist in domain or not?

I am having the following function: it checks only for valid domain, but i need to check for valid email address in domain without sending any mails.

 public boolean isValidEmailAddress(String email) {
   boolean result = true;

   try {
      InternetAddress emailAddr = new InternetAddress(email);
      emailAddr.validate();

   } catch (AddressException ex) {
      result = false;
   }
   return result;
}

回答1:


Here is a source code that could do many type of verification, I've been using it for years :

http://www.rgagnon.com/javadetails/java-0452.html

Note : see the function isAddressValid() in the page for full validation.




回答2:


Sounds like you need the SMTP VRFY command:

This command will request that the receiving SMTP server verify that a given email username is valid. The SMTP server will reply with the login name of the user. This feature can be turned off in sendmail because allowing it can be a security hole. VRFY commands can be used to probe for login names on a system. See the security section below for information about turning off this feature.

Note the security issues above though.



来源:https://stackoverflow.com/questions/13453160/how-to-check-that-the-email-id-exist-in-domain-without-sending-any-mails-using-j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!