• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting UnknownHostException!  RSS feed

 
Mani Raju
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Actually i am trying to send mail through java using destination host. But fortunately i am getting below exception.

javax.mail.MessagingException: Unknown SMTP host:
nested exception is:
java.net.UnknownHostException:
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1225)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:32 2)
at javax.mail.Service.connect(Service.java:236)
at javax.mail.Service.connect(Service.java:137)
at javax.mail.Service.connect(Service.java:86)
at javax.mail.Transport.send0(Transport.java:150)
at javax.mail.Transport.send(Transport.java:80)
java.net.UnknownHostException:
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:520)
at java.net.Socket.connect(Socket.java:470)
at java.net.Socket.<init>(Socket.java:367)
at java.net.Socket.<init>(Socket.java:240)
at com.sun.mail.util.SocketFetcher.getSocket0(SocketFetcher.java:253)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:129)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1195)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:32 2)
at javax.mail.Service.connect(Service.java:236)
at javax.mail.Service.connect(Service.java:137)
at javax.mail.Service.connect(Service.java:86)
at javax.mail.Transport.send0(Transport.java:150)
at javax.mail.Transport.send(Transport.java:80)

Anyone could please help to sort out this exception.

Thanks in advance!

 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the code that you are trying to execute.
Error simply means that Destination Host name is not being recognized on your network. Please check the validity of Host name.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you're not specifying the host at all (or not doing so correctly) - normally the name of the invalid host would be listed behind "Unknown SMTP host: ". Since that is empty, I suspect that your code does not set the host properly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!