aspose file tools*
The moose likes Java in General and the fly likes JavaMail not able to reslove hostname coming from one of the Unix server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JavaMail not able to reslove hostname coming from one of the Unix server" Watch "JavaMail not able to reslove hostname coming from one of the Unix server" New topic
Author

JavaMail not able to reslove hostname coming from one of the Unix server

Vrunda Bapat
Greenhorn

Joined: Jul 16, 2007
Posts: 3
Hi,
We are using JavaMail to send Mails via Java Application.

JavaMail is using relay server to relay mail.
Relay server is not able to relay the mail and fails with just sendException : Mail Server failed to Relay message and nothing more than that.
We get hostname like this : String currentHost = InetAddress.getLocalHost().getHostName();

According to API documentation: InetAddress.getHostName() is doing a reverse lookup on the server's IP address using the naming service (DNS) configured in your O/S.

hosname returns as mcc12345
In server configuration : /etc/hosts file

xxx.xx.xx.3 mcc12345-blah.com mcc12345-blah.com loghost
xxx.xx.xx.51 mcc12345-data.blah mcc12345 mcc12345-blah mcc12345-blah.com


Since InetAddress.getLocalHost().getHostName() returns mcc12345
JavaMail is not able to resolve it to fully qualified address.

Is there any change in /etc/hosts configuration file which would help return the correct Host name?

What else can be done other than using another method call - InetAddress.getLocalHost().getCanonicalHostName()?
Code Change is NOT an welcome OPTION at this point , so looking at configuration changes on Server to help..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaMail not able to reslove hostname coming from one of the Unix server