Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mail resource look up failed

Alex S.K. Lau
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a typical mail resource set up for my Tomcat webapp

<Resource name="mail/Session" auth="Container" type="javax.mail.Session"""></Resource>

<description>Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate SMTP server.</description>

Servlet code

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
javax.mail.Session msession = (javax.mail.Session) envCtx.lookup("mail/Session");
System.out.println("Email server is " + msession.getProperty(""));

This works fine on my development computer with Eclispse but failed once I deployed to the actual server.
with returns an exception: Could not connect to SMTP host: localhost, port: 25

My mail server is is not localhost so I put the pritnln statment to confirm that, and it is actuall localhost. I suspect that the server is totally locked down and firewalled by my IT department. Does any one know what is the context look up port so that I can try to open that port to see if it works.


  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic