• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java mail server verification.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am wondering if I am the only one with this specific problem, I whant to check if my smtp host is up and running before I attempt to send an email. Or is it better to see if I get an exception and then handles this ?
I have 3 different smtp hosts I can use, but I would preffer to test if they are running and ready to send my emails before I do it instead of using the exceptions. So my question is how do I do this ?
I did try InetAddress.getByName("w5.company.com").isReachable(1000) but they responds even if my smtp host is down, there are some webhosting here aswell.
 
U Kvistborg
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I even tried this one:
for(int i = 0 ; i<=65535;i++){
InetSocketAddress inet = new InetSocketAddress("w3.company.com", i);
System.out.println("Port " + i + " open " + inet.isUnresolved());
}

And no ports on the server where unresolved, but I know it does not listen to evet port in the range 0-65535

So again how can I detmine that my mail server is listening on the specific smtp port ?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The isUnresolved method only resolves the address - not the port. You'll have to actually open a connection to the InetSocketAddress to find out if it's open. Usually you can focus on port 25 only for SMTP servers.
 
U Kvistborg
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what you are telling me is that I just aswell could try to send the message, and then see if it fails rather than doing a check for if the port is listening.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was more talking about making a simple Socket connection to port 25, which will fail if there is no (mail) server running (on that port).
 
U Kvistborg
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help,

Currently trying all sorts of stuff I never really did before, being the only person on a project, that gets to use what ever I like as long as it lives up to the requerenments :-)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic