Total Pageviews

Monday, November 1, 2010

Modifying E-mail Notification

There are two methods to achieve it...
1. You can change the e mail notification by modifying the template at following breadcrumb :

Control Panel >> Settings >> E-mail Notification

This will change the default template in the following path:


com/liferay/portlet/admin/dependencies/


This is the easiest way to achieve. However, there is one more way which is more recommended.




2. In EXT environment, you have freedom of writing your own template and set it in portal-ext.properties file. The default one can be seen by following the mentioned path. However same variable(string literals) can be used in custom templates too.



#
# Configure email notification settings.
#
admin.email.from.name=Apoorva Prakash
admin.email.from.address=apoorvashubhi@gmail.com

admin.email.user.added.enabled=true
admin.email.user.added.subject=com/liferay/portlet/admin/dependencies/CUSTOM_email_user_added_subject.tmpl
admin.email.user.added.body=com/liferay/portlet/admin/dependencies/CUSTOM_email_user_added_body.tmpl

admin.email.password.sent.enabled=true
admin.email.password.sent.subject=com/liferay/portlet/admin/dependencies/CUSTOM_email_password_sent_subject.tmpl
admin.email.password.sent.body=com/liferay/portlet/admin/dependencies/CUSTOMemail_password_sent_body.tmpl


In the above mentioned code, I have created a new template, stored in the same path with the different name.
Available Values:
In this template few string tokens are available, which can be used.

New string tokens can be create by overriding "liferay-portal-src-5.2.3\portal-impl\src\com\liferay\portal\service\impl\UserLocalServiceImpl.java" class.

AN IMPORTANT NOTE:

When you start the the server first time, it will pickup the custom template you've created. As soon as you make some modification from Rich Text Editor window, and save it, the modified template is saved in the database in portletpreferences table. Next time, the template is picked up from the database instead custom template. Basically, liferay looks for template from the database first, if it exists there then populates the template from database, else reads the path from portal-ext.properties and loads the custom template. Database is always given priority over properties file.

8 comments:

  1. Hi there,

    Thanks for the great article. It helped me a lot. However, I have an extra question.

    I put the new email notification settings in my portal-ext.properties file. The next time I restarted the tomcat server, those properties where loaded. Working great! What I see now is that if I changes the settings through the portal it will get saved in the database, but only for one restart. If I restart again, I get the default settings (that I stored in my portal-ext.properties file) again.

    Is there a way to get it in a consistent manner? Whether this is always using the default values or making sure the settings remain stored in the database, even after the next restart?

    Kind regards,

    Felix Godts

    ReplyDelete
    Replies
    1. Hi Felix,

      Make sure you are not using Hypersonic DB(HSQL).

      Regards.

      Delete
  2. This post is very good post. I like this post.I hope that you next time same this post
    . you can Buy Email Database from us.
    Thank for your post.

    ReplyDelete
  3. Hi..

    I created my own vm files for email notification, It is my requirement. Now situation is that i created different vm files which contains html+css+image.

    Mail send successfully.

    But I can not replace with my custom data. Like in my vm file there is $$irstName$.. I am trying to find and replace it but ir not works.

    Same thing in mail, i can not see images. How can I get absolute path of that image .

    This same thing I also add image in Account Creation email template - built in, same thing i can not see that images in my mail..

    Please Help me.

    Skype: pradip.aspire
    email : pradip.bhatt@aspiresoftware.in


    Regards
    Pradip Bhatt

    ReplyDelete
  4. Hi Apoorva,
    Thanks for sharing your knowledge. Is there any other way to modify templates for message board portlet in hook or portlet plugin? I do not wish to use EXT environment.
    I have few customer specific format which says email should have truncated thread content from MB. Please let me know your inputs.

    ReplyDelete
  5. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head.
    I am highly impressed with your blog. It is very nicely explained.
    Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

    ReplyDelete