You're asking how to find mail servers, or, once you're connected to a mail server, how to find its address? Note that without the address, you can't connect to the mail server, so I'm really not sure what you're asking. Can you rephrase the question?
Well, you've got a Socket, right? Call getInetAddress() on the Socket. But if you don't know the address, how could you possibly have connected to the server in the first place?
Maybe this is a JavaMail question. Are we talking about JavaMail?