File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Vrunda Bapat
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 loghost
xxx.xx.xx.51 mcc12345-data.blah mcc12345 mcc12345-blah

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..
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic