Unit testing the Email notification
I frequently encounter the question about Unit testing the Email notification & in support while debugging time is spent waiting for a mail to arrive. In CQ, Email notification happens during "Subscription to page events", "Subscription to forum events", "Perform a step in a workflow" Or "Any custom implementation". Also based on envirnoment you might use "local Mail server", "free smtp server" etc... When you move on to next assignment the envirnoment differs. In this article I am sharing one of the mail utility developed and you might find this helpful.
- Installation & Configuration
- Non UI
Mail utility is a custom application developed using google SubEtha java library which acts as
- Platform independent Simple SMTP server.
- A Client to unit test the email notification of the received messages.
- Both command and GUI Interface
The Mail utility tool will help in following usecase scenario
- Acts as a free SMTP server program to lets you send & unit test messages directly from your local computer.
- Corporate firewall settings might block access to free SMTP accounts. Example:- gmail, etc...
- Avoid reconfiguring the SMTP server when SMTP provider changes the IPs and ports
- Avoid cleaning the Inbox has the email is not persisted after shutdown.
- Unit test the cq email notifications to users such as
- Subscription to page events
- Subscription to forum events
- Perform a step in a workflow
- Any custom implementation
- Download "mailutility.zip" and unzip into any directory it contains "smtpserverclient.jar" and "mailreader.properties".
- Start Mail utility using one of the following methods:
- If using a GUI file-system explorer, double-click the "smtpserverclient.jar" file.
- If using the command line with gui use, java -jar smtpserverclient.jar
- If gui is not supported in platform use, java -jar smtpserverclient.jar nonui
- By default the SMTP server has host name "localhost" & port number "2566". To use different value copy a valid "mailreader.properties" file into the same directory as the "smtpserverclient.jar" file and modify property file using text editor.
- CQ Configuration snapshot and more details at http://dev.day.com/docs/en/cq/current/administering/notification.html
- mailutility.zip Click Here