How to check mail address is exists or not?

后端 未结 2 1217
予麋鹿
予麋鹿 2020-12-05 10:47

I am sending email through Java using com.sun.mail.smtp.SMTPTransport.

I am successful to send the email, but SMTPTransport not giv

相关标签:
2条回答
  • 2020-12-05 10:59

    The only way to confirm an email address is to send an email to it and require the user to follow a (unique) link in the email back to your website.

    0 讨论(0)
  • 2020-12-05 11:14

    Thank you all for your responses.

    I am able to solve my problem through MX Record checking .

    I used this Link to resolve the problem. May this also be useful for someone.

    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial",
                 "com.sun.jndi.dns.DnsContextFactory");
    DirContext ictx = new InitialDirContext( env );
    Attributes attrs = ictx.getAttributes
                           ( hostName, new String[] { "MX" });
    Attribute attr = attrs.get( "MX" );
    if (( attr == null ) || ( attr.size() == 0 )) {
       attrs = ictx.getAttributes( hostName, new String[] { "A" });
       attr = attrs.get( "A" );
       if( attr == null )
             throw new NamingException
                      ( "No match for name '" + hostName + "'" );
    }
    

    Thank you.

    0 讨论(0)
提交回复
热议问题