Introduction #

This article is about setting up your SMTP server in Liferay. The example is done using a 3rd-party email account. For example, you can use your gmail account to send all notifications that come from your Liferay instance. This includes notifications from blog comments, message boards, and account registration emails.

Graphical User Interface #

In Liferay 6 and Liferay 5.2.x, you can configure the SMTP server by going to Control Panel -> Server Administration -> Mail.

Fill out the SMTP fields with your information: we will use gmail for simplicity. This is actually an easy and reliable way to run your SMTP server.

SMTP Server: smtp.gmail.com
Port: 465
[x] Use Secure Connection  << check the box
User: Your gmail username
Password: Your gmail password 

This will give you a working SMTP server!

Legacy #

In older Liferay versions, there was no Liferay GUI. You had to set this based on your app server.

Apache Tomcat #

This section shows how to configure the SMTP server with an email address in Apache Tomcat.

In the file: $LP/conf/Catalina/localhost/ROOT.xml

<!-- Mail -->

<Resource name="mail/MailSession" auth="Container" type="javax.mail.Session" mail.imap.host="localhost" mail.pop3.host="localhost" mail.smtp.host="localhost" mail.store.protocol="imap" mail.transport.protocol="smtp" />}}}

If you are using a Gmail account you should do the following:

<Resource
name="mail/MailSession"
auth="Container"
type="javax.mail.Session"
mail.imap.host="localhost"
mail.pop.host="localhost"
mail.store.protocol="imap"
mail.transport.protocol="smtp"
mail.smtp.host="smtp.gmail.com"
mail.smtp.port="465"
mail.smtp.auth="true"
mail.smtp.starttls.enable="true"
mail.smtp.user="username"
password="password"
mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
/>
0 archivos adjuntos
65035 Accesos
Promedio (3 Votos)
La valoración media es de 4.33333333333333 estrellas de 5.
Comentarios
Respuestas anidadas Autor Fecha
Supongo que cuando la cuenta no es gmail... Javier Beringola 28 de diciembre de 2008 9:06
Hi Guys, I am a having a peculiar problem.I was... Joe Veliyath 29 de junio de 2011 1:42
Notice that if you are setting this up in... Jakub Liska 18 de noviembre de 2011 17:15
Ouch, I pasted the example how it shouldn't... Jakub Liska 20 de noviembre de 2011 9:36
I have set the mail session settings as... srijani basak 18 de julio de 2012 6:02
Hi all I am trying it with 6.0.6 but it is not... me liferay 17 de diciembre de 2012 5:17

Supongo que cuando la cuenta no es gmail también habrá que especificar el nombre de usuario y contraseña para poder entrar en el servidor y envíe el correo.
Publicado el día 28/12/08 9:06.
Hi Guys, I am a having a peculiar problem.I was trying out TABS of JQUERY in liferay. I build a new portlet to get this functionality. The good news was that the TABS worked when i added the portlet.But When i refresh the page,its not working. Why is that happening ?

P.S I have used the same example as in JQUERY tabs DEMO.
Publicado el día 29/06/11 1:42.
Notice that if you are setting this up in portal-ext.properties instead of server administration, you must use secure smtp protocol : smtps . It is necessary for it to work with gmail.

mail.session.mail.smtp.auth=true
mail.session.mail.smtp.host=smtp.gmail.com­
mail.session.mail.smtp.password=
mail.session.mail.smtp.port=465
mail.session.mail­.smtp.user=
mail.session.mail.transport.protocol=smtps
Publicado el día 18/11/11 17:15.
Ouch, I pasted the example how it shouldn't look like by accident, this is correct :

mail.session.mail.smtps.auth=true
mail.session.mail.smtps.host=smtp.gmail.com
mail­.session.mail.smtps.password=
mail.session.mail.smtps.port=465
mail.session.mail.s­mtps.user=user@gmail.com
mail.session.mail.transport.protocol=smtps
Publicado el día 20/11/11 9:36 en respuesta a Jakub Liska.
I have set the mail session settings as following:
Server : smtp.gmail.com
Protocol: SMTP
User: discover.atech@gmail.com
Password: password
Verify Password: password


and added the following custom properties:


mail.smtp.host : smtp.gmail.com
mail.smtp.auth : true
mail.debug : true
mail.smtp.port: 465
mail.smtp.socketFactory.port: 465
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback false

But still I get the exception : com.ibm.websphere.personalization.rules.email.EmailDispatcher setSessionResource Unable to connect to JavaMail session. The Mail host is either down, or it has not been properly setup. You will be unable to send personalized e-mail.

In MailProvider, I have these Protocol Providers:

imap com.sun.mail.imap.IMAPStore STORE
imaps com.sun.mail.imap.IMAPSSLStore STORE
pop3 com.sun.mail.pop3.POP3Store STORE
pop3s com.sun.mail.pop3.POP3SSLStore STORE
smtp com.sun.mail.smtp.SMTPTransport TRANSPORT
smtps com.sun.mail.smtp.SMTPSSLTransport
Publicado el día 18/07/12 6:02 en respuesta a Jakub Liska.
Hi all
I am trying it with 6.0.6 but it is not accepting smtp.gmail.com as host.
Showing exception as follow.
11:45:19,801 ERROR [MailEngine:489] Unknown SMTP host: smtp.gmail.com
11:45:19,801 ERROR [MailEngine:154] java.net.UnknownHostException: smtp.gmail.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:14­1)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at com.liferay.util.mail.MailEngine._send(MailEngine.java:459)
at com.liferay.util.mail.MailEngine.send(MailEngine.java:366)
at com.liferay.util.mail.MailEngine.send(MailEngine.java:110)
at com.liferay.mail.messaging.MailMessageListener.doMailMessage(MailMessageListener­.java:101)
at com.liferay.mail.messaging.MailMessageListener.doReceive(MailMessageListener.jav­a:115)
at com.liferay.mail.messaging.MailMessageListener.receive(MailMessageListener.java:­43)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessag­eListener.java:63)
at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestinatio­n.java:61)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:8­86)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
Publicado el día 17/12/12 5:17 en respuesta a srijani basak.