Saturday, 30 March 2013

Configure Mail Server In Liferay : Simplest Way

Intended users for this post are developers. As we have to work on restricted environment, where we cannot configure complete mail server and test mails,we need a simplest way to test mailing applications.

Recently I need to test forgot functionality in liferay 6.1.1 for which we need a mail server. Google's smtp free server ( 465) is not allowed in our environment. So I have configured my own smtp server on local machine and tested the functionality. It is really simplest way to test your application.

Step 1: First configure your own mail server on your machine.
Step 2: Login to liferay as admin user, go to control panel\Server Administration\Mail and enter following details(There are default details, any way).
  • Incoming POP Server: localhost
  • Incoming Port: 110
  • User Name: root
  • Password: root
  • Outgoing SMTP Server: localhost
  • Outgoing Port: 25
  • User Name: root
  • Password: root 
and save them. 
Step 3: Click on forgot password, enter captcha, password hint and send-email-link. 
Step 4: Verify your mail here where you can see password update link.

Note: If you are using liferay 6.1.1 GA2 and default configuration of apache-james-2-3-2 then link pattern will be some thing like this,
Remove amp;from the above link, other wise forgot password link will redirect user to home page. It will not ask user for new password.

How To Setup Own Mail Server For Your Application

There are plenty of mail servers available in the market for free, hmailserver, apache-james.. are some of them. In the following post, I am going to write about configuring mail server(apache-james 2.3.2) on your own machine. This might be useful for developers to test their application in the restricted environment.
(For simplicity, I am ignoring configuration settings, and going to write about main steps, for more info you can read in apache-james site).
  1. Download apache-james 2.3.2 and unpack on your machine(Here after james-2.3.2 folder will be referred as JAMES_HOME.
  2. Go to JAMES_HOME\bin and click on run.bat, if the mail server runs successfully, following screen can be seen
  3.  You are almost there. To test whether you have configured your mail server properly, open command prompt and try this command. telnet localhost 25, then you can see a scree like this.
  4. Now use out going smtp server as localhost or and port as 25. (You can modify these details in conf.xml and host file). 
  5. Send a mail from your application and check your out box/inbox here.