The Form-To-Mail package is designed to work somewhat like formmail.pl - the user enters information into an HTML form on a page, and upon submitting the page the data is collected and emailed to an address of the administrator's choosing.
Form-to-Mail (FTM) is designed with reuse, and hopefully some security, in mind. Email addresses such as sender and recipient are configured by the administrator, stored in the database, and cannnot be overridden by form variables, which limits abuse of the form by third parties.
FTM is designed to be included on other pages in the site, and provides a facility for adding custom form elements to the form, using a .tcl file that can be as simple or complex as the developer requires. The package uses a single instance to generate the included HTML form, and to process the submitted form.
Form-to-Mail is made up of two pages: form and form-proc. To add a mail form to your site, first mount an instance of Form-To-Mail under your site. The name of the instance doesn't really matter, but there should be only one instance and it would be good to name it something generic but that does not give away its purpose (i.e., naming it "Form-to-Mail" is likely to invite malcontents to try and abuse it). I like to use 'ftm'.
Visit /yoursite/<ftm-instance>/admin. (Replace <ftm-instance> with whatever you named your Form-to-Mail instance.
Add a new form, entering the information as requested:
On the page or template where you want the form to appear, include it like this:
<include src="/packages/form-to-mail/www/form" form_name="name of the form" extra_form_file="/path/to/file">
ad_form -extend -name mail_form -form { { ftmx.field1:text ... } { ftmx.field2:text(select) ... } }
The form name, "mail_form", is the name of the form generated by the package and should not be changed.
In the call to ad_form, your form elements should be named with "ftmx." as a prefix. This adds the form element to an array passed to the form processor, and makes sure that it gets added to the outgoing email.
You can use whatever techniques you want to generate your form elements. One popular technique might be to fetch a list of values from the database to create the options for a select input (drop-down list element). Another might be grabbing the url of the current page to pass as a hidden field and thereby sent with the email.
I would be completly remiss if I did not thank the denizens of #openacs - especially daveb, jadeforrest, jim, jaufrec, michaels, talli, and til - for their help, encouragement, and patience with a complete n00b.
Form-to-Mail Package, Steve Ivy, steve@redmonk.net, 2003