Forums

Home » Liferay Portal » English » Liferay Legacy

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Medusa Gorgon
Mail service configuration
November 2, 2006 3:55 AM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

Hello everybody,
I am unable to find any thread or document that could explain me how to configure email service/ email portlet for liferay portal 4.0.
My abmbiguities are:
1- Does liferay has an email server bundled with it or i will need to install a seperate one?
2- if no, then which email servers are supported by liferay 4.0 ?
3- Does configuring email service/ email portlet has anything to do with the mysql database that i have installed ?
4- the best link that i found was http://www-361.liferay.com/web/guest/documentation/development/mail
but this is for the older version of liferay and the links in it dont work anymore, is there such a document for 4.0?

awaiting positive response.
regards
Medusa Gorgon
RE: Mail service configuration
November 2, 2006 9:47 PM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

Can someone please give some attention to this thread. i guess the response will be useful for several other people.
regards
Joseph Shum
RE: Mail service configuration
November 3, 2006 2:03 AM
Answer

Joseph Shum

LIFERAY STAFF

Rank: Expert

Posts: 336

Join Date: May 16, 2006

Recent Posts

1- Does liferay has an email server bundled with it or i will need to install a seperate one?

no. you need to install one.

2- if no, then which email servers are supported by liferay 4.0 ?

http://content.liferay.com/4.0.0/docs/developers/ch02s04.html

3- Does configuring email service/ email portlet has anything to do with the mysql database that i have installed ?

yes, look at the docs. the Cyrus mail server uses the db for auth info.

4- the best link that i found was http://www-361.liferay.com/web/guest/documentation/development/mail
but this is for the older version of liferay and the links in it dont work anymore, is there such a document for 4.0?


see #2.


the documentation should help you better understand how liferay works with the mail server.
Medusa Gorgon
RE: Mail service configuration
November 3, 2006 3:51 AM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

Thanks joseph, You relly did cleared out some things. I have a few more questions left,

1- Does this means i cannot use my organization's mail server which is Sun Java Mail Server?
2- The documentation linked that you provided assumes in its first page that we are using liferay professional 3.2 bundled with tomcat. I am using unbundled liferay( ear file) that i have deployed on jboss/tomcat. The location of the files mentioned in the document does not exist. What should i do to implement the steps in jboss?

regards
Mika Koivisto
RE: Mail service configuration
November 3, 2006 1:09 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

Medusa Gorgon:

1- Does this means i cannot use my organization's mail server which is Sun Java Mail Server?
2- The documentation linked that you provided assumes in its first page that we are using liferay professional 3.2 bundled with tomcat. I am using unbundled liferay( ear file) that i have deployed on jboss/tomcat. The location of the files mentioned in the document does not exist. What should i do to implement the steps in jboss?


Question nr 1: Yes you can. I'm using hmailserver in my dev environment which is Windows XP and I didn't want to install MS Exchange. So I chose hmailserver which supports SMTP, IMAP and POP. btw it's wicked small and easy to install and administer. So there was no support for that particular mail server and it required email address as the username instead of userId that Liferay assumes. So I wrote a small patch and opened a JIRA task LEP-1531. I don't need any fancy automatic account creation etc. that is provided to the supported mailserver so I didn't write a hook for that mailserver. Now if you need such funktionality you could easily create that by implementing com.liferay.mail.util.Hook and once you have done that hopefully provide that back to the community as a improvement request in JIRA with a implementation perhaps.

Question nr 2: Just configure your javamail session with mail.imap.host pointing to you IMAP server and if you can authenticate to it via your liferay userid and password then your set. If not then you might need to override the authentication implementation in MailUtil somewhere around line 1400.

Hope this helps.

--
http://javaguru.fi
Medusa Gorgon
RE: Mail service configuration
November 5, 2006 11:39 PM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

Thanks for the help mika,
if that works, its exactly what i wanted. but here are the results:
I edited JBOSS_HOME/server/default/deploy/mail-service.xml

<?xml version="1.0"?>

<server>
<mbean code="org.jboss.mail.MailService" name="jboss:service=MailSession">
<attribute name="JNDIName">mail/MailSession</attribute>
<attribute name="User">test</attribute>
<attribute name="Password">test</attribute>
<attribute name="Configuration">
<configuration>
<property name="mail.store.protocol" value="imap" />
<property name="mail.transport.protocol" value="smtp" />
<property name="mail.imap.host" value="mymailhost.com" />
<property name="mail.pop3.host" value="mymailhost.com" />
<property name="mail.smtp.host" value="mymailhost.com" />
</configuration>
</attribute>
</mbean>
</server>



a user with the id test and password test was created on my mail server. Upon startup of jboss, i received the followin errors:

11:43:30,462 WARN [ServiceController] Problem starting service jboss:service=MailSession
....
....
Caused by: java.net.SocketTimeoutException: Receive timed out

and upon startup of liferay i received

--- MBeans waiting for other MBeans ---
ObjectName: jboss:service=MailSession
State: FAILED
Reason: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss:service=MailSession
State: FAILED
Reason: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

What can be the reasons? can anybody help?

regards
Medusa Gorgon
RE: Mail service configuration
November 5, 2006 11:45 PM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

The contents of mail-service.xml are:
 1
 2<server>
 3        <mbean code="org.jboss.mail.MailService" name="jboss:service=MailSession">
 4                <attribute name="JNDIName">mail/MailSession</attribute>
 5                <attribute name="User">test</attribute>
 6                <attribute name="Password">test</attribute>
 7                <attribute name="Configuration">
 8                        <configuration>
 9                                <property name="mail.store.protocol" value="imap" />
10                                <property name="mail.transport.protocol" value="smtp" />
11                                <property name="mail.imap.host" value="mymailhost.com" />
12                                <property name="mail.pop3.host" value="mymailhost.com" />
13                                <property name="mail.smtp.host" value="mymailhost.com" />
14                        </configuration>
15                </attribute>
16        </mbean>
17</server>
Medusa Gorgon
RE: Mail service configuration
November 7, 2006 3:17 AM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

I just removed the errors that i was getting, The reason is still unknown , but i replaced my application server from installable jboss jar to jboss*GA.zip and everything started working fine. The problem now is that for every user i only see the test user inbox . Perhaps it is because thats what i provided in mail-service.xml. I know i am making a stupid mistake but i need help as i cant get any clue my self. Please someone help me
regards
Mika Koivisto
RE: Mail service configuration
November 7, 2006 4:17 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

You need to remove following lines:

1                 <attribute name="User">test</attribute>
2                 <attribute name="Password">test</attribute>


The mail portlet provides the username and password for the current portal user.
Medusa Gorgon
RE: Mail service configuration
November 8, 2006 3:07 AM
Answer

Medusa Gorgon

Rank: New Member

Posts: 14

Join Date: August 29, 2006

Recent Posts

Thanx, it really worked now.
as i said , one silly small mistake.
for this thread to be one comprehensive support for new liferay testers. My next questions are:
1-does liferay support IMAPS and or SMTPS?
2-Is there a way to synchronize password between liferay and my mail server?

regards
Mika Koivisto
RE: Mail service configuration
November 8, 2006 4:48 AM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1513

Join Date: August 7, 2006

Recent Posts

Medusa Gorgon:
1-does liferay support IMAPS and or SMTPS?

Haven't tried but I would assume it is possible if JavaMail supports it.

Medusa Gorgon:
2-Is there a way to synchronize password between liferay and my mail server?

Try the hooks there are couple ready made hooks for Cyrys and Redhat Enterprise Mail server etc. Check the configuration in portal.properties
hugh J. Savoie
RE: Mail service configuration
November 9, 2006 9:22 AM
Answer

hugh J. Savoie

Rank: New Member

Posts: 7

Join Date: October 6, 2006

Recent Posts

Medusa Gorgon,

Please if you got this working can you help me.

I'm using Windows XP
Liferay 4.1.2
MySql
hmailserve
javainside@msn.com
hugh J. Savoie
RE: Mail service configuration
November 16, 2006 6:02 AM
Answer

hugh J. Savoie

Rank: New Member

Posts: 7

Join Date: October 6, 2006

Recent Posts

I got this working.

1. I modified mail-service.xml to point to my email server.

2. I changed MailUtil to pass the user email instead of the userid
String imapHost = session.getProperty("mail.imap.host");
String eMail = "";
String userId = (String)ses.getAttribute(WebKeys.USER_ID);
String serviceName =
userId + StringPool.COLON + WebKeys.MAIL_STORE;

try {
User user = UserLocalServiceUtil.getUserById(userId);
eMail = user.getEmailAddress();
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
String password = (String)ses.getAttribute(
WebKeys.USER_PASSWORD);

store = session.getStore("imap");

store.addConnectionListener(
new ConnectionListener(serviceName));

//store.connect(imapHost, userId, password);
store.connect(imapHost, eMail, password);

3. I created a triger on lportal.user_ to insert a record into the mail db user accounts whenever a user was created in the portal
DELIMITER $$

DROP TRIGGER `lportal`.`createMailAccount`$$

create trigger `createMailAccount` AFTER INSERT on `users_roles`
for each row BEGIN
insert into mail.hm_accounts (accountaddress, accountpassword, accountdomainid, accountactive) select emailAddress, password_, '1' ,'1'
from lportal.user_ WHERE createDate=(SELECT MAX(lportal.user_.createDate) from lportal.user_);

END;
$$

DELIMITER ;
MIchael A Ikhane
RE: Mail service configuration
November 10, 2006 3:38 AM
Answer

MIchael A Ikhane

Rank: New Member

Posts: 7

Join Date: September 25, 2006

Recent Posts

Hi Mika Koivisto,

I have been searching for how to use the mail portlet in liferay 4.1.2+tomcat to work with exchange server. reading this post has realy given me succour, though i have not installed the hmail yet. i have downloaded it and your patch as well. if u are not too busy, i would like to kno how u did the configuration of liferay to work with the server and how u installed the two patches.

thanks
Michael emoticon
Anonymous
RE: Mail service configuration
November 15, 2006 12:24 PM
Answer

Anonymous

I'm using exim as mail server and UWIMAP. on the portal.properties I'm using SendMail hook and it seems working fine if I put one account on mail-service.xml.
Can you tell me how to configure for multiple account?? I did take a look at the available doc from liferay (http://content.liferay.com/4.0.0/docs/developers/ch02s04.html) but that's for older version. do we still need to do those thing for 4.1.2? and since looks like it will be easier for version 4.2 for multiple account, can you tell me when 4.1.2 supposed to be released. Here is what I did so far:

1. Change portal.properties to use sendMail hook
2. change username and password to one of the mail account and it works fine
but if I changed to the default one which is "nobody" and "password" then it will give me java mail authentication error.
3. change the property of mail.replace = true

do I missed something? can you please give me step by step of how to do it?
Do we still need to install expect package just like the older version?


Please help me . Thanks.