Difference between revisions of "Web Hosting Feedback Script"

From SchoolsWiki
Jump to: navigation, search
Line 1: Line 1:
 
== NMS FormMail ==
 
== NMS FormMail ==
 
[[Image:Nms.g‎if||right]]
 
[[Image:Nms.g‎if||right]]
 
 
NMS FormMail is a drop-in replacement for Matt Wright's FormMail script. It converts an HTML form submission to an email message.
 
NMS FormMail is a drop-in replacement for Matt Wright's FormMail script. It converts an HTML form submission to an email message.
 
 
  
 
== Form Configuration ==
 
== Form Configuration ==
  
 
+
To make use of it, you need to write an HTML form that refers to the FormMail script. Here's an example which will send mail to the address 'feedback@your.domain' when someone submits the form:
To make use of it, you need to write an HTML form that refers to the
 
 
 
FormMail script. Here's an example which will send mail to the address
 
 
 
'feedback@your.domain' when someone submits the form:
 
  
 
<pre>
 
<pre>
Line 24: Line 16:
 
</pre>
 
</pre>
  
 +
See how the hidden 'recipient' input in the example above told formmail who to send the mail to ? This is how almost all of formmail's configuration works. Here's the full list of things you can set with hidden form inputs:
  
See how the hidden 'recipient' input in the example above told formmail who
+
== Configuration Variables ==
 
 
to send the mail to ? This is how almost all of formmail's configuration
 
 
 
works. Here's the full list of things you can set with hidden form inputs:
 
 
 
 
 
=== Configuration Variables ===
 
 
 
recipient              - The email address to which the form submission
 
 
 
                          should be sent. If you would like it copied to
 
 
 
                          more than one recipient then you can separate
 
 
 
                          multiple email addresses with commas, for
 
  
                          example:
+
=== recipient ===
  
 +
The email address to which the form submission should be sent. If you would like it copied to more than one recipient then you can separate multiple email addresses with commas, for example:
  
 
<pre>
 
<pre>
                          <input type="hidden" name="recipient"
+
<input type="hidden" name="recipient"
 
+
      value="you@your.domain,me@your.domain" />
                                value="you@your.domain,me@your.domain" />
 
 
</pre>
 
</pre>
  
 +
If you leave the 'recipient' field out of the form, formmail will send to the first address listed in the @allow_mail_to configuration variable (see above).  This allows you to avoid putting your email address in the form, which might be desirable if you're concerned about address harvesters collecting it and sending you SPAM. This feature is disabled if the $emulate_matts_code configuration variable is set to 1.
  
                          If you leave the 'recipient' field out of the
+
=== subject ===
 
 
                          form, formmail will send to the first address
 
 
 
                          listed in the @allow_mail_to configuration
 
 
 
                          variable (see above).  This allows you to avoid
 
 
 
                          putting your email address in the form, which
 
 
 
                          might be desirable if you're concerned about
 
 
 
                          address harvesters collecting it and sending
 
 
 
                          you SPAM. This feature is disabled if the
 
 
 
                          $emulate_matts_code configuration variable is
 
 
 
                          set to 1.
 
 
 
 
 
 
 
subject                 - The subject line for the email. For example:
 
  
 +
The subject line for the email. For example:
  
 
<pre>
 
<pre>
                          <input type="hidden" name="subject"
+
<input type="hidden" name="subject"
 
+
      value="From the feedback form" />
                                value="From the feedback form" />
 
 
</pre>
 
</pre>
  
 +
=== redirect ===
  
redirect                - If this value is present it should be a URL, and
+
If this value is present it should be a URL, and the user will be redirected there after a successful form submission.  For example:
 
 
                          the user will be redirected there after a
 
 
 
                          successful form submission.  For example:
 
 
 
  
 
<pre>
 
<pre>
                          <input type="hidden" name="redirect"
+
<input type="hidden" name="redirect"
 
+
value="http://www.your.domain/foo.html" />
                          value="http://www.your.domain/foo.html" />
 
 
</pre>
 
</pre>
  
 +
If you don't specify a redirect URL then instead of redirecting formmail will generate a success page telling the user that their submission was successful.
  
                          If you don't specify a redirect URL then instead
+
=== bgcolor ===
 
+
                          of redirecting formmail will generate a success
+
The background color for the success page.
 
 
                          page telling the user that their submission was
 
 
 
                          successful.
 
 
 
 
 
 
 
bgcolor                 - The background color for the success page.
 
 
 
 
 
 
 
background              - The URL of the background image for the success
 
 
 
                          page.
 
 
 
 
 
 
 
text_color              - The text color for the success page.
 
 
 
 
 
 
 
link_color              - The link color for the success page.
 
 
 
 
 
 
 
vlink_color            - The vlink color for the success page.
 
 
 
  
 +
=== background ===
  
alink_color            - The alink color for the success page.
+
The URL of the background image for the success page.
  
 +
=== text_color ===
  
 +
The text color for the success page.
  
title                  - The title for the success page.
+
=== link_color ===
  
 +
The link color for the success page.
  
 +
=== vlink_color ===
  
return_link_url        - The target URL for a link at the end of the
+
The vlink color for the success page.
  
                          success page. This is normally used to provide
+
=== alink_color ===
  
                          a link from the success page back to your main
+
The alink color for the success page.
  
                          page or back to the page with the form on. For
+
=== title ===
 
+
 
                          example:
+
The title for the success page.
  
 +
=== return_link_url ===
 +
 
 +
The target URL for a link at the end of the success page. This is normally used to provide a link from the success page back to your main page or back to the page with the form on. For example:
  
 
<pre>
 
<pre>
                          <input type="hidden" name="return_link_url"
+
<input type="hidden" name="return_link_url"
 
+
value="/home.html" />
                          value="/home.html" />
 
 
</pre>
 
</pre>
  
 +
=== return_link_title ===
  
return_link_title      - The label for the return link.  For example:
+
The label for the return link.  For example:
 
 
  
 
<pre>
 
<pre>
                          <input type="hidden" name="return_link_title"
+
<input type="hidden" name="return_link_title"
 
+
value="Back to my home page" />
                          value="Back to my home page" />
 
 
</pre>
 
</pre>
  
 
+
=== sort ===
sort                    - This sets the order in which the submitted form
+
   
 
+
This sets the order in which the submitted form inputs will appear in the email and on the success page.  It can be the string 'alphabetic' for alphabetic order, or the string "order:" followed by a comma separated list of the input names, for example:
                          inputs will appear in the email and on the
 
 
 
                          success page.  It can be the string 'alphabetic'
 
 
 
                          for alphabetic order, or the string "order:"
 
 
 
                          followed by a comma separated list of the input
 
 
 
                          names, for example:
 
 
 
  
 
<pre>
 
<pre>
                          <input type="hidden" name="sort"
+
<input type="hidden" name="sort"
 
+
value="order:name,email,age,comments" />
                          value="order:name,email,age,comments" />
 
 
</pre>
 
</pre>
  
 +
If "order:" is used you must supply the names of all of the fields that you want to be in the body of the mail message.
  
                          If "order:" is used you must supply the names of
+
=== print_config ===
 
+
   
                          all of the fields that you want to be in the body of
+
This is mainly used for debugging, and if set it causes formmail to include a dump of the specified configuration settings in the email. For example:
 
 
                          the mail message.
 
 
 
 
 
 
 
print_config            - This is mainly used for debugging, and if set it
 
 
 
                          causes formmail to include a dump of the
 
 
 
                          specified configuration settings in the email.
 
 
 
                          For example:
 
 
 
 
 
 
 
                          <input type="hidden" name="print_config"
 
 
 
                          value="title,sort" />
 
 
 
 
 
 
 
                          ... will include whatever values you set for
 
 
 
                          'title' and 'sort' (if any) in the email.
 
 
 
 
 
 
 
required                - This is a list of fields that the user must fill
 
 
 
                          in before they submit the form. If they leave
 
 
 
                          any of these fields blank then they will be sent
 
 
 
                          back to the form to try again.  For example:
 
 
 
 
 
 
 
                          <input type="hidden" name="required"
 
 
 
                          value="name,comments" />
 
 
 
 
 
 
 
missing_fields_redirect - If this is set, it must be a URL, and the user
 
 
 
                          will be redirected there if any of the fields
 
 
 
                          listed in 'required' are left blank. Use this if
 
 
 
                          you want finer control over the the error that
 
 
 
                          the user see's if they miss out a field.
 
 
 
 
 
 
 
env_report              - This is a list of the CGI environment variables
 
 
 
                          that should be included in the email.  This is
 
 
 
                          useful for recording things like the IP address
 
 
 
                          of the user in the email. Any environment
 
 
 
                          variables that you want to use in 'env_report' in
 
 
 
                          any of your forms will need to be in the
 
 
 
                          @valid_ENV configuration variable described
 
 
 
                          above.
 
 
 
 
 
 
 
print_blank_fields      - If this is set then fields that the user left
 
 
 
                          blank will be included in the email.  Normally,
 
 
 
                          blank fields are suppressed to save space.
 
  
 +
<input type="hidden" name="print_config"
 +
value="title,sort" />
  
 +
... will include whatever values you set for 'title' and 'sort' (if any) in the email.
  
As well as all these hidden inputs, there are a couple of non-hidden
+
=== required ===
  
inputs which get special treatment:
+
This is a list of fields that the user must fill in before they submit the form. If they leave any of these fields blank then they will be sent back to the form to try again.  For example:
  
 +
<input type="hidden" name="required"
 +
value="name,comments" />
  
 +
=== missing_fields_redirect ===
  
email    - If one of the things you're asking the user to fill in is their
+
If this is set, it must be a URL, and the user will be redirected there if any of the fields listed in 'required' are left blank. Use this if you want finer control over the the error that the user see's if they miss out a field.
  
          email address and you call that input 'email', formmail will use
+
=== env_report ===
  
          it as the address part of the sender's email address in the
+
This is a list of the CGI environment variables that should be included in the email.  This is useful for recording things like the IP address
 +
of the user in the email. Any environment variables that you want to use in 'env_report' in any of your forms will need to be in the
 +
@valid_ENV configuration variable described above.
  
          email.
+
=== print_blank_fields ===
  
 +
If this is set then fields that the user left blank will be included in the email.  Normally, blank fields are suppressed to save space.
  
 +
As well as all these hidden inputs, there are a couple of non-hidden inputs which get special treatment:
  
realname - If one of the things you're asking the user to fill in is their
+
=== email ===
  
          full name and you call that input 'realname', formmail will use
+
If one of the things you're asking the user to fill in is their email address and you call that input 'email', formmail will use it as the address part of the sender's email address in the email.
  
          it as the name part of the sender's email address in the email.
+
=== realname ===
 +
If one of the things you're asking the user to fill in is their full name and you call that input 'realname', formmail will use it as the name part of the sender's email address in the email.

Revision as of 11:33, 8 October 2008

NMS FormMail

Nms.gif

NMS FormMail is a drop-in replacement for Matt Wright's FormMail script. It converts an HTML form submission to an email message.

Form Configuration

To make use of it, you need to write an HTML form that refers to the FormMail script. Here's an example which will send mail to the address 'feedback@your.domain' when someone submits the form:

<form method="post" action="http://your.domain/cgi-bin/FormMail.pl">
  <input type="hidden" name="recipient" value="feedback@your.domain" />
  <input type="text" name="feedback" /><br />
  Please enter your comments<br />
  <input type="submit" />
</form>

See how the hidden 'recipient' input in the example above told formmail who to send the mail to ? This is how almost all of formmail's configuration works. Here's the full list of things you can set with hidden form inputs:

Configuration Variables

recipient

The email address to which the form submission should be sent. If you would like it copied to more than one recipient then you can separate multiple email addresses with commas, for example:

<input type="hidden" name="recipient"
      value="you@your.domain,me@your.domain" />

If you leave the 'recipient' field out of the form, formmail will send to the first address listed in the @allow_mail_to configuration variable (see above). This allows you to avoid putting your email address in the form, which might be desirable if you're concerned about address harvesters collecting it and sending you SPAM. This feature is disabled if the $emulate_matts_code configuration variable is set to 1.

subject

The subject line for the email. For example:

<input type="hidden" name="subject"
      value="From the feedback form" />

redirect

If this value is present it should be a URL, and the user will be redirected there after a successful form submission. For example:

<input type="hidden" name="redirect"
 value="http://www.your.domain/foo.html" />

If you don't specify a redirect URL then instead of redirecting formmail will generate a success page telling the user that their submission was successful.

bgcolor

The background color for the success page.

background

The URL of the background image for the success page.

text_color

The text color for the success page.

link_color

The link color for the success page.

vlink_color

The vlink color for the success page.

alink_color

The alink color for the success page.

title

The title for the success page.

return_link_url

The target URL for a link at the end of the success page. This is normally used to provide a link from the success page back to your main page or back to the page with the form on. For example:

<input type="hidden" name="return_link_url"
 value="/home.html" />

return_link_title

The label for the return link. For example:

<input type="hidden" name="return_link_title"
 value="Back to my home page" />

sort

This sets the order in which the submitted form inputs will appear in the email and on the success page. It can be the string 'alphabetic' for alphabetic order, or the string "order:" followed by a comma separated list of the input names, for example:

<input type="hidden" name="sort"
 value="order:name,email,age,comments" />

If "order:" is used you must supply the names of all of the fields that you want to be in the body of the mail message.

print_config

This is mainly used for debugging, and if set it causes formmail to include a dump of the specified configuration settings in the email. For example:

<input type="hidden" name="print_config"

value="title,sort" />

... will include whatever values you set for 'title' and 'sort' (if any) in the email.

required

This is a list of fields that the user must fill in before they submit the form. If they leave any of these fields blank then they will be sent back to the form to try again. For example:

<input type="hidden" name="required"

value="name,comments" />

missing_fields_redirect

If this is set, it must be a URL, and the user will be redirected there if any of the fields listed in 'required' are left blank. Use this if you want finer control over the the error that the user see's if they miss out a field.

env_report

This is a list of the CGI environment variables that should be included in the email. This is useful for recording things like the IP address of the user in the email. Any environment variables that you want to use in 'env_report' in any of your forms will need to be in the @valid_ENV configuration variable described above.

print_blank_fields

If this is set then fields that the user left blank will be included in the email. Normally, blank fields are suppressed to save space.

As well as all these hidden inputs, there are a couple of non-hidden inputs which get special treatment:

email

If one of the things you're asking the user to fill in is their email address and you call that input 'email', formmail will use it as the address part of the sender's email address in the email.

realname

If one of the things you're asking the user to fill in is their full name and you call that input 'realname', formmail will use it as the name part of the sender's email address in the email.