Verify if an email address exists or not

落爺英雄遲暮 提交于 2019-12-12 16:18:35

问题


I successfully done validation of mail address but I want some suggestions for verifying an email address. The main point is when user enter an email id it should b checked that it is real or just a fake id. Any suggestion?


回答1:


No, this facility is not available. You can verify only when you have your own mail server the you are authorized to check the mail id is valid or not. Or when you own other server then you are permitted to get the mirror image of all others mail server only then you can verify, So if you are just a user of mail id then you can verify that the mail id is valid or not.

You can only verify the correct format of mail id by pattern checking.

Have fun




回答2:


You can only check whether entered E-mail id is validate or not using regular expression, its not possible to check whether id is exists or not? as per my knowledge.

check out this link its already well answered




回答3:


public static void main(String[] args) throws Exception {
 String email = null;
 String dns = null;

 BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter email address to validate: ");
email = reader.readLine();
System.out.print("Enter DNS hostname to perform domain validation (e.g. ns.myhost.com): ");
dns = reader.readLine();
// create EmailInspector instance
EmailInspector inspector = new EmailInspector();

// enable debugging
inspector.setDebug(true);

// set DNS server
inspector.setNameserver(dns);

// set validation level
inspector.setEmailInspectionLevel(inspector.DOMAIN_VALIDATION);

// validate email
inspector.validate(email);
}

}






 .  Create new EmailInspector instance.
    .  Enable debugging.
    .  Set DNS server to be used for looking up domains.
    .  Set validation level.
    .  Validate email address.



回答4:


Properties props = System.getProperties();

    props.put("mail.smtp.user", senderEmail);
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "465");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.debug", "true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.socketFactory.port", "465");
    props.put("mail.smtp.socketFactory.class", 
          "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");

    // Required to avoid security exception.
    email.MyAuthenticator authentication = 
          new email.MyAuthenticator(senderEmail,senderMailPassword);
    Session session = 
          Session.getDefaultInstance(props,authentication);
    session.setDebug(true);


来源:https://stackoverflow.com/questions/13319622/verify-if-an-email-address-exists-or-not

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