Tuesday, March 10, 2009

How to send an email from (WCM) Web Content Management

Problem
How can you create and use an email form in Web Content Management?


Resolving the problem
Web Content Management (WCM) can be enabled to use your SMTP server for sending e-mail. This e-mail enablement is generally used for the e-mail workflow action feature, and it is possible to utilize this feature to send email in other parts of WCM, such as the HTML Component.
As an example, you can use an HTML component to write an HTML form which contains basic email properties. The HTML Component (HTML Form) can post the form data to the built-in WCM e-mail module, which can then relay the form data to your SMTP mail server.



Enable Web Content Management to send email


First, you must enable WCM to send email. Read the Web Content Management information center topic "Enabling e-mail for Web Content Management" for details.


To utilize the e-mail workflow action, configure Web Content Management to use your environment's SMTP server.

Edit the WCMConfigService.properties file.

File location:
Windows: portal_server_root/wcm/shared/app/config/wcmservices
UNIX: portal_server_root/wcm/shared/app/config/wcmservices
i5/OS: portal_server_root/wcm/shared/app/config/wcmservices


Ensure the following settings are configured to use the SMTP server:

connect.connector.mailconnector.defaultsmtpserver=mail.yourmailserver.com
default.system-email=admin@yourmailserver.com
connect.connector.mailconnector.defaultreplytoaddress=admin@yourmailserver.com


Save the WCMConfigService.properties file.


Restart the WCM/Portal server for the new settings to take effect.


Create an HTML Component


Create an HTML Form and store it in the HTML Component.


Create a friendly URL mapping to a Portal Page.

NOTE: This action is accomplished through the portal's administration features. Read the information center topic Infocenter section regarding Portal URL Mapping.
If you wish to have the form redirect to a page which uses the WCM Local Rendering Portlet to display a "thank you page", add the WCM_GLOBAL_CONTEXT url parameter to the redirect url in form post section.


Update the HTML Component form post URL with the correct URL mapping for the post redirect This setting redirects one to the page that will display upon successful e-mail submission.


Configure the WCM Content Preview portlet to access your HTML Component.


Send email and verify it works as expected.



Create an HTML Form to be used as the e-mail form

This example uses the HTML Component.

The fully qualified hostname to the WCM server and reference the WCM e-mail module are specified In the form's post action section . This post action includes a redirection to a URL mapping. After the e-mail is successfully submitted, the form is redirected to the mapped URL.








to:
from:
subject:
email:






To create a custom URL mapping in Portal, create a new URL mapping by creating a new context and mapping it to your desired Portal page.


Example: Create a new URL mapping context named "TestPAGE" and map the context to the portal paged named "MyTestingPage"









Update the HTML form's redirect URL to point to the URL mapping context.





NOTE: The WCM_GLOBAL_CONTEXT is only needed if you are intending to redirect to a page where the WCM content viewer portlet is installed and you want the content viewer to display the content item specified in the value of the WCM_GLOBAL_CONTEXT. In this example, redirection targets a content item named "ThankYouPage".





Configure the WCM Content Preview portlet to access the html component (e-mail form).






Send email and verify it works as expected.

When the mail is successfully sent, the redirect parameter will take you to the mapped page you created. This is the test page which has the WCM Content Preview portlet installed. The WCM_GLOBAL_CONTEXT is used to specify the wcm item you want to render in the WCM Content Preview Portlet. In this example, it simple displays a content item named "ThankYouPage".

NOTE: The WCM Content Preview Portlet you redirect to must be configured to accept broadcasts from other portlets otherwise the WCM_GLOBAL_CONTEXT value will not update the portlet as expected.