This website uses cookies to ensure you get the best experience. Learn More.
Sometimes ... things do not go to plan when using mail (email) in Liferay Portal.
However you can quickly find the cause by logging the outbound mail message.
You can enable additional logging to help trace inbound and outbound mail.
NOTE: This article was extracted from article How to configure Google Mail in Liferay Portal
The following configuration has been tested with these products:
The configuration may also be suitable for these products:
Enable logging via Control Panel or Log4j configuration file.
See below for Control Panel configuration.
See appendix for sample Log4j configuration file.
Enable logging level ALL (TRACE) for one or more of the following categories using "Control Panel > Server Administration > Log Levels"
Enable logging level ALL (TRACE) for one or more of the following categories using "Dockbar > Admin > Control Panel > Server Administration > Log Levels"
The JavaMail API supporta a "debug" mode in which mail messages are logged to standard output (stdout).
This can be useful when tracing message headers and/or content.
To enable the JavaMail debug mode, configure the DEBUG (or ALL) logging level for either of these logging (categoriy) entries :
This loggig configuration is equivalent to the following JavaMail API code:
java.util.Properties properties = ... javax.mail.Session session = Session.getInstance(properties); session.setDebug(true);
For the curious, the Liferay Portal 6.2 mail debug logic in class com.liferay.util.MailEngine.
FILE: TOMCAT/lib/ext/META-INF/portal-log4j-ext.xml
NOTE: Adapt the following sample porta log4j configuration file to suit your testing requirements.
NOTE: Change the timezone definition from {Australia/Perth} to your local timezone, or remove entry to default to GMT/UTC.
e.g.
<?xml version="1.0"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" WARN="true" debug="true"> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.EnhancedPatternLayout"> <param name="ConversionPattern" value="%d{ISO8601}{Australia/Perth} %-5p [%t][%c{1}:%L] %m%n" /> </layout> </appender> <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender"> <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="FileNamePattern" value="@liferay.home@/logs/liferay@spi.id@.%d{yyyy-MM-dd}.log" /> </rollingPolicy> <layout class="org.apache.log4j.EnhancedPatternLayout"> <param name="ConversionPattern" value="%d{ISO8601}{Australia/Perth} %-5p [%t][%c{1}:%L] %m%n" /> </layout> </appender> <category name="com.liferay.mail.messaging"> <priority value="ALL" /> </category> <category name="com.liferay.mail.service"> <priority value="ALL" /> </category> <category name="com.liferay.mail.service.impl"> <priority value="ALL" /> </category> <category name="com.liferay.mail.service.impl.MailServiceImpl"> <priority value="ALL" /> </category> <category name="com.liferay.portal.util.SubscriptionSender"> <priority value="ALL" /> </category> <category name="com.liferay.portlet.mail"> <priority value="ALL" /> </category> <category name="com.liferay.portlet.announcements.messaging.CheckEntryMessageListener"> <priority value="ALL" /> </category> <category name="com.liferay.portlet.announcements.service"> <priority value="ALL" /> </category> <category name="com.liferay.portlet.announcements.service.impl.AnnouncementsEntryLocalServiceImpl"> <priority value="ALL" /> </category> <category name="com.liferay.util.mail"> <priority value="ALL" /> </category> <category name="com.liferay.util.mail.MailEngine"> <priority value="ALL" /> </category> </log4j:configuration>