|
|
|
Using the MailIt Module for Simple Form-Based Email By Joe Follansbee, joef@follansbeeconsulting.com Nearly every Web site includes a page that invites users to send e-mail to the Web site owner. More and more of these pages use a Web form for e-mail communication. This tutorial explains how to use the MailIt module with the Caudium Web server to add simple form-based email capability to a Web site. Requirements
I’ve attempted to write this tutorial for a new Caudium user with little
or no experience using RXML, the markup language used by Caudium. However,
a basic knowledge of HTML and programming logic is helpful. You will need:
Installing Caudium
If you have not already installed Caudium, please see Bill Welliver’s Caudium
Installation Tutorial.
Installing MailIt
Download the MailIt module from the Roxen Module Source Web site, http://source.riverweb.com/
and place it in a convenient directory. Log in as root, cd to the directory
where you downloaded the MailIt tarball, and run these commands:
Adding MailIt to Your Caudium Virtual Servergzip –d mailit-1.8.tar.gz tar xvf mailit-1.8.tar cd mailit-1.8 At this point, it’s a good idea to review the README file for important information. Also, check out the examples in the “/examples/” subdirectory. Then copy the mailit.pike module to your Caudium server tags directory. cp mailit.pike /usr/local/caudium/server/modules/tags/ Modify the directory location to suit your Caudium installation, if different from the defaults.
This part of the tutorial assumes you have a working Caudium installation
and have created a virtual server. To add the MailIt module:
MailIt Configuration
That’s it! MailIt is now installed.
Most users will be able to use MailIt without any further configuration.
However, it’s a good idea to check its configuration anyway. Click the MailIt
module link, and note the options, in particular the location of the Sendmail
binary. (Sendmail is the most popular e-mail system on UnixUnix®® and *nix clone
systems and installed by default on almost all installations. You can use
MailIt without knowing anything about Sendmail. If your operating system places
sendmail somewhere other than MailIt's default, you should make sure that you provide
the correct location.)
Using MailIt
For the purposes of this tutorial, we’ll build a simple set of three Web
pages.
For More Information
Only send.html will contain MailIt tags. form.html Create an HTML page with a form for entering an email address, a subject, and the message. Here’s some sample form code. Note the ACTION attribute. <FORM ACTION="send.html" METHOD="post"> To: <INPUT TYPE="text" NAME="to"><BR> From: <INPUT TYPE="text" NAME="from"><BR> Subject: <INPUT TYPE="text" NAME="subject"><BR> Message: <TEXTAREA NAME="message" ROWS=”5” COLS=”50” WRAP="true"></TEXTAREA><BR> <INPUT TYPE="submit" NAME="send" VALUE="Send"><BR> </FORM> To see how the form looks, click here . send.html This is where the action is, literally! send.html contains the MailIt tags, which are interpreted by Caudium to send the e-mail written in form.html. Here’s all the code for send.html. If you copy and paste this into your code, be sure to remove the comments in parentheses! <HTML> <HEAD><TITLE>MailIt Tutorial Send Script</TITLE></HEAD> <BODY> This is a sample send script for the MailIt tutorial.<BR><BR> (This RXML container tells Caudium to insert the form values into the script.) <formoutput> (The opening of the MailIt container.) <mailit> (This tells MailIt who sent the mail and who gets the email. They're the values of the TEXT HTML tag with the names (keys) "to" and "from". Note carefully the "#" character on either side of "to" and “from”. Without these, the formoutput container won't insert the form values, and MailIt won't know where to address the mail "to" and “from”.) <mailheader name="to" value="#to#"> <mailheader name="from" value="#from#"> (This inserts the Subject value of the key/value pair from the TEXT HTML tag named "Subject". The "quote=dtag" part takes care of problems that might be caused by odd characters in the subject. Note again the use of the "#" character on either side of the inserted value.) <mailheader subject="#subject:quote=dtag#"> (This is the opening tag of the actual message container, and it's where the body of the email message goes.) <mailmessage encoding="7bit">#message# (The closing tag for the message.) </mailmessage> (The closing tag for MailIt.) </mailit> (The closing tag for the <formoutput> RXML container.) </formoutput> (This tells Caudium to redirect the sender to another page. This avoids a second email sent due to an accidental reload of send.html.) <header name="Location" value="redirect.html"> <return code=302> </FORM> </BODY> </HTML> redirect.html redirect.html is a plain HTML page with a message saying the email was successful. As mentioned above, we use this to avoid a second email due to an accidental reload of send.html. You’ve now completed the Using the MailIt Module for Simple Form-Based Email tutorial!
Copyright 2002, Joseph G. Follansbee. The HTML and MailIt tag code in this document is released under terms of the GPL. MailIt module copyright 1997 Bill Welliver. |
|
Copyright © 2000 - 2005
The Caudium Group
All Rights Reserved. Hosting by Kazar.
|
|
|
"Unix" is a registered trademark of The Open Group |
|