Home : OpenEdit SDK : Programming OpenEdit : Html Mail Forms
Html Mail Forms
Add a Contact / Feedback Form to your OpenEdit site
To create HTML forms by adding any arbitrary fields to an HTML page. This works for simple mail forms. If you require valid ation we recommend using JavaScript as the user fills in the form.
Entering Data
Create an HTML page in any directory you like, such as this one /feedback/index.html:
<form method="post" name="emailform" action="thankyou.html">
Enter in some text here: <input type="text" name="somefield" />< br />
<input type="submit" value="Submit" />
</form>
The action of the form should be the thank you page, which the user will see after submitting the form.
The .xconf configuration file for that page will specify the action to send the email, as well as the properties that determine the parameters of the email.
thankyou.xconf :
<page>
<path-action name="Email.sendEmail" />
<property name="to">sales@openedit.org</property>
<property name="from">sales@openedit.org</property>
<property name="subject">Survey Results</property>
<property name="e-mail_layout">/feedback/emaillayout.html</property>
</page>
If some of those values should be variable, then they must be specified in the form. So, for example, if we wanted the user to input the subject of the email, the new form would be:
<form method="post" name="emailform" action="thankyou.html">
Enter in some text here: <input type="text" name="somefield" />< br />
<input type="hidden" name="subject" value="Some Subject" /> <br />
<input type="submit" value="Submit" />
</form>
Also, remove the "subject" property from the .xconf file, or else it will override the input in the form.
Formating The Email
Create the body of the email such as this file emaillayout.html:
<html>
<body> >
Email has been received with this in it:
$!context.getRequestParameter("somefield")
</body>
</html>
Configuring the SMTP server
The editor system comes preconfigured to use an SMTP server on "localhost" without authentication. This is sufficient for most people and won't need to be changed. If you need to change the server or use
authentication, follow the below directions.
The SMTP server settings are now configured in WEB-INF/pluginoverrides.xml.
For example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="postMail" class="com.openedit.modules.email.PostMail" >
<property name="smtpSecured"><value>true</value></property>
<property name="smtpUsername"><value>username@myserver.com</value></property>
<property name="smtpPassword"><value>mySecretPassword</value></property>
<property name="smtpServer"><value>some.smtp.server</value></property>
<property name="port"><value>25</value></property>
</bean>
</beans>
