You are not logged in Log in Join
You are here: Home » Members » maxm » A list of my How-To's » Simple mailForm How-To

Log in
Name

Password

 

Simple mailForm How-To

Introduction

Often clients wants simple mail forms on their site that is used to send the content of a form to a specific employee in the company. This doesn't take long for a single form, but then clients are clients and if some forms are good, more forms must be better.

It can then easily take a lot of unproductive time to do the layout write the dtml and do input verification, error messages etc.

I have made this zClass to simplify this process. 10-30 minutes of work can be done in less than 5 minutes.

IF you only need simple input validation that is. It can only verify if a form field is empty or not.

How do i set it up?


First you must set up a mailhost somewhere where you mailForm can reach it through acquisition. If you are new to Zope, here is how it looks.

It must be called "mailer", or you should change the reply method in the mailForm zClass and find the line that reads:

<dtml-sendmail mailhost="mailer">

Here you can change the name to that of your own mailhost.


Then you must add the mailForm somewhere on your site. You do this the usual way.

Then you must set the properties of the mailForm: Some fields will be filled out with default values. Feel free to change those.

postForm:

This is the form you want the user to fill out. It is whatever usually stands between <form> and </form> in normal html. the default looks like this:

Subject:<br>
<input type="text" name="1) Subject"><br>
Message:<br>
<textarea name="2) Message" cols="60" rows="10"></textarea><br>  

Notice!! the "name" value in the input tags. The first input field has the name "1) Subject" this is done because the output is sorted alphabetically both on the reply page on the website, and in the e-mail send to you.

The name is also used as part of the reply page and the e-mail, but this should be more obvious below.

It should be possible to use any form tags in the form.

title

The title that this page will have. The same title is used as subject in the e-mail send to you.

to

Who should receive this mail

from

The email adress of the person that will appear as the sender of this mail.

mailReply

The text that will appear in the mail that the receiver will get.

webReply

The text that will apear on the webpage that the user will se as a reply to submitting data.

submitButton

What is the text on the submit button? Usually "Submit" but "Send" in my native tongue.

resetButton

What is the text on the reset button? Usually "Reset" but "Nulstil" in my native tongue.

required

Names of the input fields that must not be empty

missingWarning

If one of those input fields are ampty, this text will be there instead.

errorMessage

The message that the user will se if one or more of the required fields are empty.


A typical user session wil then look like this:

Empty form:

Form that isn't filled out correctly. [The "1) Subject" is required.]

The result:

A correctly filled out form:

The reply to that:

So that is that. Hopefully somebody has some use for it.

Please feel free to contact me at [email protected] in case of trouble or feature requests.

Regards Max M

get it here