BareMetal.com

Baremetal
My Account
Domain Registration Management Services
Web Services
Rates and Specs
Bulk Rates
CGI Library
FAQ
Order Form
Tech Support
Billing Info
Company Info
Charities
Legal Info
Employment
Privacy Statement

BM


Web Services

Form data -> Formatted E-mail;

Return CGI Library
Return Form Handling

OK... hopefully you've seen example 1 where we covered the most basic use of this gadget. Now we're going to shift our attention to polishing up the content of the e-mail message.

In the last example there was a lot of duplicated information in the resulting e-mail message. For reference, here it is again:


FROM: some@where.else.com
------------------
SUBJECT: Put a subject here
------------------
TO: tbrown
------------------
feedback: This is just a simple demonstration example.
------------------
realname: Tom Brown
------------------

The FROM, TO, and SUBJECT lines are all presented in the e-mail header, so we really don't need to see them in the message body. [In the future we might provide a simple switch to turn them off.]

A better formatted message might have read:


Tom Brown (some@where.else.com) said:

This is just a simple demonstration example.

In order to accomplish this (or any other formatting), we need to provide a "template" that tells the gadget what we want the output to look like. The templates page covers templates in detail, so we'll just run through the example here.

Here's the very simple template we're going to use:

{realname} ({FROM}) said:

{feedback}

We'll put it into "/gadgets/mail2/page2.tpl" which we need to know to write the form.

Here is the modified simple sample form with the changes in bold:


<form action="/cgi-bin/mail2" method="post">
<input type="hidden" name="TEMPLATE" value="/gadgets/mail2/page2.tpl" />
<input type="hidden" name="TO" value="support@baremetal.com" />
<input type="hidden" name="SUBJECT"
          value="Demo Form from Page1 of /cgi-bin/mail2 docs" />

Who are you?   <input type="text" name="realname" /> <br />
e-mail address: <input type="text" name="FROM" /> <br />
Feedback: <textarea name="feedback" cols="50" rows="10">
          </textarea> <br />
<input type="submit" value="Tell us" />
</form>

Here is a link to an implementation of it. We've still left the hidden fields as text fields so that you can easily try it with your own values.

We'll leave it as an exercise to the reader to see that it works :-).


OK. Let's explain what we just did.

We created the simple template shown above and stored it in a file.

We then added a hidden field named TEMPLATE and stored the path to the template in it. Note that the path to the template is relative to the top of the webserver directory... i.e. it's the same as the URL to the template without the http://host/ part.


Summary of key points:

  • The TEMPLATE field defines a the path to a template to be used to format the contents of the e-mail response generated by the gadget.

  • If a value for TEMPLATE is specified, then a TO value must also be specified. (Which makes sense, as you can't send a formatted e-mail message without having an address to send it to.)



 
Home Page    Domain Registration Services    Web Services    Technical Support
About Baremetal    Privacy Statement    Billing Info    Charities
My Account    Legal Info    Search BareMetal

Copyright © 1996-2012, BareMetal.com Inc.
Last updated: Thursday, 28-May-2015 16:14:56 PDT
Last Accessed from: 5.181.190.175
Questions and comments to support@baremetal.com