Help me in finding the Server IP from an email address

jose_sam
jose_sam used Ask the Experts™
on
Hello all,

I want to find the Ip of the machine of the SMTP server, given an email address.... I found there is some way of doing this thorught JNDI or something like that.... But its not so clear.. Can some one please give me a simple example that clearly shows how to do the above purpose?

Thanks in advance,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I'm not sure exactly how you would do it in java code.  If you run nslookup, and execute the "set type=MX" command, you can pull it.  

$ nslookup
> set type=MX
> yahoo.com

yahoo.com       preference = 1, mail exchanger = mx1.mail.yahoo.com
yahoo.com       preference = 5, mail exchanger = mx4.mail.yahoo.com
yahoo.com       preference = 1, mail exchanger = mx2.mail.yahoo.com

Depending on what you need, you might be able to execute an "nslookup" type query within java, and pull that data.

What is the data for?

Author

Commented:
Thanks for the reply..
I want to do it from a java program... I am trying to develop an smtp server...

Commented:
so you need to implement your own DNS libarary (or find some OpenSource)
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Author

Commented:
Thanks for the reply..
I want to do it from a java program... I am trying to develop an smtp server...
Top Expert 2016

Commented:
Or Runtime.exec nslookup until you can find the right libraries
Commented:
"The Java Apache Mail Enterprise Server (a.k.a. Apache James)" has DNS implementaion.

http://jakarta.apache.org/james/configuration_v2_0.html

Commented:
or if you are using Java 1.4 you can use JavaSoft's implementation

"DNS Service Provider for the Java Naming Directory InterfaceTM (JNDI)"

http://java.sun.com/j2se/1.4/docs/guide/jndi/jndi-dns.html
Commented:
By substring-ing the email domain, you can reverse that to an IP address.  I think you should look into java.net package.  

try {
      java.net.InetAddress otherInet =
            java.net.InetAddress.getByName("banjo");
      System.out.println(otherInet.getHostAddress());
} catch (Exception e) {
    e.printStackTrace();
}
jose_sam:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between thetool721 , heyhey_ and tutran

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial