Debugging mail sessions
When you debug a mail application, we can use the mail debugging feature. The mail component generates debugging information, on a per session basis, that can be used for problem determination or tuning.
Enable the debug mode triggers the mail component of the application server to print the following data to the standard output stream:
- interactions with the mail servers
- properties of the mail session
This output stream is redirected to the SystemOut.log file for the specific application server.
This topic references one or more of the application server log files. As a recommended alternative, we can configure the server to use the High Performance Extensible Logging (HPEL) log and trace infrastructure instead of using SystemOut.log , SystemErr.log, trace.log, and activity.log files on distributed and IBM i systems. We can also use HPEL in conjunction with the native z/OS logging facilities. If we are using HPEL, we can access all of the log and trace information using the LogViewer command-line tool from the server profile bin directory. See the information about using HPEL to troubleshoot applications for more information on using HPEL.
- Open the console.
- Click Resources > Mail > Mail sessions > mail session.
- Click Enable debug mode. Debugging is enabled for that session only.
- Click Apply or OK.
Example
The following example shows sample mail debugging output:
ResourceMgrIm I WSVR0049I: Binding Test as mail/test SystemOut O *** In SessionReferenceable.getReference: SystemOut O added StringRefAddr: type=ws.transport.password, content=**** SystemOut O added StringRefAddr: type=ws.isolated.class.loader, content=false SystemOut O added StringRefAddr: type=mail.transport.protocol, content=smtp SystemOut O added StringRefAddr: type=mail.imaps.class, content=com.sun.mail.imap.IMAPSSLStore SystemOut O added StringRefAddr: type=mail.smtp.host, content=smtp.coldmail.com SystemOut O added StringRefAddr: type=mail.debug, content=true SystemOut O added StringRefAddr: type=mail.pop3s.class, content=com.sun.mail.pop3.POP3SSLStore SystemOut O added StringRefAddr: type=mail.from, content=smith@coldmail.com SystemOut O added StringRefAddr: type=mail.smtp.class, content=com.sun.mail.smtp.SMTPTransport SystemOut O added StringRefAddr: type=mail.smtps.class, content=com.sun.mail.smtp.SMTPSSLTransport SystemOut O added StringRefAddr: type=mail.imap.class, content=com.sun.mail.imap.IMAPStore SystemOut O added StringRefAddr: type=mail.smtp.user, content=smith SystemOut O added StringRefAddr: type=mail.pop3.class, content=com.sun.mail.pop3.POP3Store SystemOut O added StringRefAddr: type=mail.mime.address.strict, content=true SystemOut O DEBUG: JavaMail version 1.4ea SystemOut O DEBUG: java.io.FileNotFoundException: C:\IBM\WebSphere\AppServer\java\jre\lib\javamail.providers (The system cannot find the file specified.) SystemOut O DEBUG: !anyLoaded SystemOut O DEBUG: not loading resource: /META-INF/javamail.providers SystemOut O DEBUG: successfully loaded resource: /META-INF/javamail.default.providers SystemOut O DEBUG: Tables of loaded providers SystemOut O DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider [TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider [TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider [STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider [STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider [STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider [STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]} SystemOut O DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems,Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems,Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]} SystemOut O DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map SystemOut O DEBUG: !anyLoaded SystemOut O DEBUG: not loading resource: /META-INF/javamail.address.map SystemOut O DEBUG: java.io.FileNotFoundException: C:\IBM\WebSphere\AppServer\java\jre\lib\javamail.address.map (The system cannot find the file specified.) SystemOut O *** In SessionFactory.setPasswordAuthentication, TRANSPORT PasswordAuthentication is based on: SystemOut O url=smtp://smith@smtp.coldmail.com SystemOut O user=smith SystemOut O password=**** SystemOut O *** In SessionFactory.getObjectInstance, session properties: SystemOut O mail.transport.protocol=smtp SystemOut O mail.imaps.class=com.sun.mail.imap.IMAPSSLStore SystemOut O mail.smtp.host=smtp.coldmail.com SystemOut O mail.debug=true SystemOut O mail.pop3s.class=com.sun.mail.pop3.POP3SSLStore SystemOut O mail.from=smith@coldmail.com SystemOut O mail.smtp.class=com.sun.mail.smtp.SMTPTransport SystemOut O mail.smtps.class=com.sun.mail.smtp.SMTPSSLTransport SystemOut O mail.imap.class=com.sun.mail.imap.IMAPStore SystemOut O mail.smtp.user=smith SystemOut O mail.pop3.class=com.sun.mail.pop3.POP3Store SystemOut O mail.mime.address.strict=true SystemOut O DEBUG: mail.smtp.class property exists and points to com.sun.mail.smtp.SMTPTransport SystemOut O DEBUG SMTP: useEhlo true, useAuth false SystemOut O DEBUG SMTP: trying to connect to host "smtp.coldmail.com", port 25, isSSL false javax.mail.MessagingException: Unknown SMTP host: smtp.coldmail.com; nested exception is: java.net.UnknownHostException: smtp.coldmail.com at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370) at javax.mail.Service.connect(Service.java:275) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at com.ibm.ws.mail.ut.TestServlet.doTask(TestServlet.java:104) at com.ibm.ws.mail.ut.TestServlet.doGet(TestServlet.java:65) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1397) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:759) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:429) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3512) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:273) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:896) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1530) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:161) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202) at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1487) Caused by: java.net.UnknownHostException: smtp.coldmail.com at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:196) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250) ... 32 moreThis output illustrates a connection failure to a Simple Mail Transfer Protocol (SMTP) server because a fictitious name, smtp.coldmail.com, is specified as the server name.
The following list provides tips on reading the previous sample of debugger output:
- The lines headed by DEBUG are printed by the mail provider at run time, while the two lines headed by *** are printed by the application server at run time.
- In the second paragraph of code, the first few lines state that some configuration files are skipped. The mail component attempts to load a number of configuration files from different locations at run time. All those files are not required. If a required file cannot be accessed, however, the mail component creates an exception. In this sample, there is no exception and the third-line announces that default providers are loaded.
- The next few lines, headed by either Providers Listed by Class Name or Providers Listed by Protocols, show the protocol providers that are loaded. The six providers listed are the default protocol providers that come under the built-in mail provider for the application server. If we install special service providers, and these providers are used in the current mail session, those providers are listed here with the default providers.
- The two lines headed by *** and the few lines below them are printed by the application server to show the configuration properties of the current mail session. Although these properties are listed by their internal name rather than the name you establish in the console, we can recognize the relationships between them. For example, the mail.store.protocol property corresponds to the Protocol property in the Incoming Mail Properties section of the console panel for mail session configuration. Review the listed properties and values to verify that they correspond.
- The few lines above the exception stack show the mail activities when sending a message. First, the JavaMail API recognizes that the transport protocol is set to SMTP and that the com.sun.mail.smtp.SMTPTransport provider exists. Next, the output log displays the useEhlo and useAuth parameters, used by SMTP. Finally, the log shows the SMTP provider trying to connect to the smtp.coldmail.com mail server.
- The output log show the exception stack next. This data indicates that the specified mail server either does not exist or is not functioning.
Related tasks
Use High Performance Extensible Logging to troubleshoot applications