For internal development on Liferay, it may be useful to install a local mail server in order to test mail functionality for things like out-of-the-box forms and Kaleo workflows. It is possible to configure Liferay to use an external mail provider like Gmail , but many corporate networks disallow SMTP traffic or block certain ports. In such cases, a local mail server provides a self-contained environment to test mail functionality and email formatting.
Download the latest version of Apache James. Version 2.3.2 is the latest stable version and the following instructions assume this version rather than the 3.0 beta where the command-line interface has been streamlined.
The package appropriate for your system can be found at http://james.apache.org/download.cgi#Apache_James_Server. For Windows, select the “Binary (ZIP Format)” link.
Unzip the files to C:apache-james-2.3.2 or the directory of your choosing.
Apache James handles much of its functionality through mailets, which are described as email processing agents. Basically, they’re plugins that are compatible with any mail server that is a mailet container. In this case, we’re interested in the mailet that sends out email and changing the configuration to loop back to the same computer.
Open config.xml in C:apache-james-2.3.2appsjamesSAR-INF (mailetcontainer.xml in directory /conf/ if you’re using James 3.0).
Find the RemoteDelivery mailet entry and delete it entirely from the configuration (that is, everything from to since you will otherwise have malformed XML and James will fail to start).
In place of the deleted entry, add the following:
<mailet match="All" class="Forward"> <forwardto>test@localhost</forwardto> </mailet>
The final step to configure James is to create an email address to send mail to. The address is completely arbitrary and you can create as many addresses as you like.
First start up the mailserver and verify that it’s started successfully. Next, open a command window and type:
telnet localhost 4555
If you you’re running Windows and don’t have telnet installed, you can easily do so by opening Control Panel and selecting Programs and Features (for Windows 7). You can then choose “Turn Windows features on or off” and checking “Telnet client”.
A prompt for the user name will appear and, unless you’ve changed the configuration, use “root” and the same for the password. You will be able to create a user to correspond to the email you entered in your configuration file by typing:
adduser test test
Go to the Liferay Control Panel at https://localhost:8080/group/control_panel/
Select Server Administration from the left menu under the Server section and choose the Mail tab
Make sure the following values are set in that section:
You should be able to test your settings by performing an action in the Liferay portal that sends an email. The “Forgot password” functionality with the default Sign In portlet that ships with Liferay is a nice and quick example, requiring only that you have a user configured with the firstname.lastname@example.org email you set up. If all goes successfully, you should see the email from Liferay pop up in the mail spool in James (a Repository.FileStreamStore file) along with a matching internal file (Repository.FileObjectStore).
If you just want to see the raw emails and verify that mails are being sent, you don’t need to actually set up an email client. However, in order to view emails and to ensure they’re properly formatted, you may wish to install a client like Thunderbird to simplify things.
Run the installer and open the client
With the New Account Wizard, skip creating a new email and use an existing email.
Then select Continue. Thunderbird will attempt to look up settings and fail. Use the default entries with localhost as the Server hostname and the correct port numbers.
Accept the warning about security since I think we can trust our local mailserver and don’t want to try to set up .
Select the newly created account and Get mail. You should see the test email(s) in the mail spool download to the client.