<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>
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("mail.smtp.host"));
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.