How I configured Liferay to use Gmail as my SMTP server

 

I figured out how to do this when I was testing the message board subscriptions and the web form portlet.

Configure your ROOT.xml to look like this:

<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"

/>

 

Of course, don't forget to change username and password to your gmail username and password.  

Do not add @gmail.com to your username.  Just your username is fine.

 

Now Liferay will be able to send out emails using your gmail account.

 

Test it by using the web form portlet.  Make sure to configure the portlet to send the web form info to the email address you want.  Submit your form and you should get an email from the gmail account you just set up.

 

Blogs
Cool! I never thought about using gmail as my mail server. Thanks for the info!
Worked well for me thanks, we have an internal mail server so I used :

mail.smtp.host="smtp.ourmailserver.com"
mail.smtp.port="25"
mail.smtp.auth="true"
mail.smtp.user="username"
password="password"
There's an interesting peculiarity about gmail. The gmail smtp server modifies the 'From' field in such a way that the display name remains intact, while the address part of this field is changed to the gmail address, regardless of what the original 'From' value might be. Sometimes it may be not desired for real-life applications...
I have also noticed that gmail has no objections against appending '@gmail.com' to username.
We are using Liferay 4.2.
I'm trying to understand how to get the email functionality working from the message boards. I don't even want full listserv capabilites, just an email sent when a new topic is added to a thread or an exising topic changed.
I sort of understand the changes to Root.xml but am unsure if I can use our mail server by substituting smtp.gmail.com with smtp.ourcompanymail.com. I have tried this but nothing happens.
One question I have is do you still need to add the SMTP section to portal-ext.properties as well as changing Root.xml?
Adam T's reply says he used:
mail.smtp.host="smtp.ourmailserver.com"
mail.smtp.port="25"
mail.smtp.auth="true"
mail.smtp.user="username"
password="password"

So this is all that's required in the Resource section of Root.xml (apart from adding our mail server), or do I still need to add the SMTP section to portal-ext.properties?
I've tried this solution with no joy.
I've read all forum & wiki articles relating to setting up mail functionality from the message boards and none have been helpful so far.
I don't have a lot of technical knowledge so if anybody has any suggestions it would be helpful to have detail on what I need to do.

Thanks for your help.
Add this lines of code in your portal-ext.properties

mail.session.mail.pop3.host=pop.gmail.com

mail.session.mail.pop3.password=PASSWORD

mail.session.mail.pop3.port=110

mail.session.mail.pop3.user=USER

mail.session.mail.imap.host=imap.gmail.com

mail.session.mail.imap.port=993

mail.session.mail.store.protocol=imap

mail.session.mail.transport.protocol=smtp

mail.session.mail.smtp.host=smtp.gmail.com

mail.session.mail.smtp.password=PASSWD

mail.session.mail.smtp.user=USERID@gmail.com

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



* Please user your password in place of PASSWD and your gmail user id in place of USERID.

By three different ways we can configure mail server in Liferay. I am using Liferay 6.2 and initially I got an error that could not connect to smtp host localhost port 25 in liferay by using different code. So I used above code and my mail server is configured properly and my application is able to send mail to the user in forgot password case.

And please see this link. This link help me to solve the issue.

https://www.permeance.com.au/web/tim.telcik/home/-/blogs/how-do-i-configure-liferay-portal-to-use-google-mail

Thanks

asif aftab
[...] sagar limbu: i am trying to use password reset functionality on liferay 6.1. Gmail is the worst service to test email connectivity, but you have to at least configure it correctly for it to work.... [...] Read More