Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why
« Back to Installation

Mail Integration

This is an article on the entire Liferay mail system. For a quick setup guide for sending email notifications, see SMTP Setup.

Introduction #

There are two parts involved in configuring a mail system integrated with Liferay:

  1. Install the mail server itself. (Or choose to use a 3rd party mail server)
  2. Configure Liferay to be able to read and send emails..

Prerequisite #

Setting up Liferay mail requires that you've installed an SMTP server and an IMAP server. If you do not want to set up your own servers, you can alternatively use 3rd party servers (e.g. a gmail account).

Configuration #

Liferay 6 #

In Liferay 6, all mail configurations need to be set through the GUI. You can do this by going to Control Panel -> Server Administration -> Mail. For an SMTP example, see SMTP Setup.

Liferay v5.2 and later #

Liferay v5.2 has unified the configuration of JavaMail so that it's the same for all application servers. Note it can be configured through portal(-ext).properties using the following properties:

    mail.session.mail.imap.host=localhost
    mail.session.mail.pop3.host=localhost
    mail.session.mail.smtp.host=localhost
    #mail.session.mail.smtp.password=
    #mail.session.mail.smtp.user=
    mail.session.mail.store.protocol=localhost
    mail.session.mail.transport.protocol=smtp

Previous versions #

It's easy, just configure JavaMail in your app. server to be able to find the SMTP and IMAP servers. It is the same for Linux and Windows. Just follow the documentation.

Read here for more details: Mail (JavaMail) Setup For External .WAR Portlets

If you wish to have your app server manage the JavaMail connection information, but you are on Liferay 5.2 and later, you may add the following to your ext-spring.xml:

        <bean id="mailSession" class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="mail/MailSession" />
	</bean>

Troubleshooting #

Want to send mails but you see nothing outgoing? Liferay send email asynchronously. That means various portlets dump emails into a local queue (at least on the JBoss build), which is then worked off towards the mailserver. You can get some insight by setting the Log4j category com.liferay.util.mail to DEBUG, then run whatever should send a mail,then have a look at the logfile (server.log for JBoss).

If you experience Liferay does send email upon account creation but does not send password reset links, ensure that the user interface has both options ticked:

  • Allow users to request forgotten passwords?
  • Allow users to request password reset links?

It seems the password reset link requires the request forgotten password option - and if not set there is no message, neither in the logfile nor the UI.

0 Attachments
88819 Views
Average (3 Votes)
The average rating is 2.0 stars out of 5.
Comments
Threaded Replies Author Date
Hi Amos, 3 questions about your post : 1) I... Nicolas G. April 15, 2009 3:21 AM
I could do with some help with this as well,... Hamish Campbell June 20, 2009 2:23 PM
I am also trying to setup mail notification... Deepak Sharma October 18, 2009 12:05 PM
Need full settings in Java Mail (using GMail as... Jonas Yuan November 7, 2009 8:10 AM
Hi Jonas, I read your reply to this bug. Does... Rice Owl December 11, 2009 8:40 PM
Correction: I'm using MailServiceUtil class,... Rice Owl December 11, 2009 8:45 PM
The Liferay 6 way seems not to work with TLS... Reinaldo Silva December 3, 2010 5:54 PM
I'm still getting the ... Brian Scott Schupbach May 2, 2011 12:31 PM
HI. Did you make some other changes in the... Erick Rosales June 27, 2014 10:49 AM

Hi Amos,

3 questions about your post :

1) I am using Liferay 5.2.3 (trunk rev 29840): I noticed that new users don't receive notifications anymore with this version. Does that mean that now portal-ext.properties needs to be changed for having new users being notified by default ?

2) Which Mail Domain need I to indicate under Control Panel / Setting / General for having JavaMail sending a notification (as before = Liferay 5.1.2)?

3) What is the purpose of the "Mail Host Names" section under the Control Panel / Settings ? Do I need to configure it now for having my users notified now ? Any documentation on that section ?

Please let me know,
Regards,
Nico
Posted on 4/15/09 3:21 AM.
I could do with some help with this as well, have tried to configure it for http://visionontv.org but it dosent work. We are using Gmail as mail provider.
Posted on 6/20/09 2:23 PM in reply to Nicolas G..
I am also trying to setup mail notification mechanism for liferay portal but its not working.
Also I dont see any logs or error message.I am a beginer anb its really confusing and frustrating to not find any solution after lot of research.

Here is my configuration in portal-ext.properties

mail.session.mail.smtp.auth=true
mail.session.mail.smtp.host=smtp.gmail.com
mail.session.mail.smtp.password=password
mail.session.mail.smtp.port=465
mail.session.mail.smtp.user=username
mail.session.mail.smtp.starttls.enable=true
mail.session.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.session.mail.store.protocol=pop3
mail.session.mail.transport.protocol=smtp

Is there anything else to do? Also there is confusion on ControlPanel-->Settings --> mail domain and virtual host.
what should be the values for mail domain and virtual host??

Thanks,
DS
Posted on 10/18/09 12:05 PM in reply to Hamish Campbell.
Need full settings in Java Mail (using GMail as an example) like:

mail.session.mail.pop3.host=pop.gmail.com
mail.session.mail.pop3.password=
ma­il.session.mail.pop3.port=110
mail.session.mail.pop3.user=
mail.session.mail.imap.­host=imap.gmail.com
mail.session.mail.imap.port=993
mail.session.mail.store.protoc­ol=imap
mail.session.mail.transport.protocol=smtp
mail.session.mail.smtp.host=smtp.gmail.com
mail.session.mail.smtp.password=password
mail.session.mail.smtp.user=user
mail.session.mail.smtp.port=465
mail.session.mail.smtp.auth=true
mail.session.mail.smtp.starttls.enable=true
mail.session.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory

http://­issues.liferay.com/browse/LPS-5466
Posted on 11/7/09 8:10 AM in reply to Deepak Sharma.
Hi Jonas,

I read your reply to this bug. Does this bug cover a problem with MailEngine sending emails out? I don't seem to have problems with LifeRay sending create account emails or forgot password emails, but I have some code that uses the MailEngine.

Previous, I was using localhost (my own mail server) to send emails, but decided to go with RackSpace email hosting. I've been going nuts over it not working properly. One note - it does work for forgot password functionality, but it isn't working for my own portlet that uses the LifeRay MailEngine class. It doesn't error out, no apparent problems, except that it never does send the email.

In addition, I've updated the context.xml file, server.xml file, ext-spring.xml.. just about everything i could think of. Any tips? And previously, when I was using localhost as my mail server, it all did work fine. Seems like the problem is with trying to use the RackSpace email hosting. And I did verify accounts and passwords of course.
Posted on 12/11/09 8:40 PM in reply to Jonas Yuan.
Correction: I'm using MailServiceUtil class, not MailEngine
Posted on 12/11/09 8:45 PM in reply to Rice Owl.
The Liferay 6 way seems not to work with TLS over plain text authentication. The log show the following error:

ERROR [MailEngine:154] javax.net.ssl.exception: Unrecognized ssl message, plaintext connection?

To make it work I had to return to the portal-ext.properties style and specify all properties, with special attention to include:

mail.smtp.starttls.enable=true

And exclude (or comment);

#mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
Posted on 12/3/10 5:54 PM.
I'm still getting the

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

error. Here are my settings..does anyone see anything? I'm using version 6.0.6

mail.session.mail.pop3.host=****
mail.session.mail.pop3.password=****
ma­il.s­ession.mail.pop3.port=110
mail.session.mail.pop3.user=****
mail.session.mail.imap.­­host=****
mail.session.mail.imap.port=993
mail.session.mail.store.protoc­ol=imap
m­ail.session.mail.transport.protocol=smtp
mail.session.mail.smtp.host=****
mail.ses­sion.mail.smtp.password=****
mail.session.mail.smtp.user=****
mail.session.mail.sm­tp.port=25
mail.session.mail.smtp.auth=true
mail.session.mail.smtp.starttls.enable­=true
#mail.session.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
Posted on 5/2/11 12:31 PM in reply to Reinaldo Silva.
HI. Did you make some other changes in the Control Panel in order to get it work? Or the parameters in Control Panel > Mail are ignored with this configuration?

Thanks in advance for your advice.
Posted on 6/27/14 10:49 AM in reply to Reinaldo Silva.