Desktop and Server Virtualisation Specialist 

Twitter LinkedIn E-mail
Precedence Technologies Ltd
Technology House, 36a Union Lane
Cambridge, CB4 1QB, United Kingdom
T: +44 (0)8456 446 800 / +44 (0)1223 359900
E: enquiries@precedence.co.uk

Using a mail reply form on your web site

Often, you will want to have a page on your website that allows visitors to send you email messages without them having to use and configure a mail package. To do this, Precedence Internet provides the facility to convert an HTML form to an email message.

This service is only available to Precedence Internet customers with web-hosting accounts. All other access will be blocked

There are two stages to setting up a mail reply form: a) the HTML must be created to give the right information and b) you must configure the mail form software so that it knows where to send the mails to.

Writing the HTML

Your form needs to return the following variables
  • name - The nameof the sender
  • email - The email address of the sender
  • subject - The subject of the message
  • message - The message itself
In addition, you may specify other values as well, depending on the information you wish to get returned from the form. For instance, you may want a separate postal address field or phone number. In this case, your form should return a variable in the format: field[description]. If your description contains spaces, you must make sure that you have quotes around the name in your HTML (see Phone number in the example below). Any variables returned in this way will be included at the top of the email with the given description as a header.

The form needs to be submitted to http://www.ptlnet.com/mailback/ with method=POST

An example code segment is shown below (form components are highlighted):

<form method=POST action="http://www.ptlnet.com/mailback/">
<table width=70% align=center cellspacing=0>
  <tr bgcolor=#33cc99>
    <td align=center colspan=2><h1>Email us</h1></td>
  </tr>
  <tr bgcolor=#33ffcc>
    <td>Your name</td>
    <td><input type=text size=60 name=name></td>
  </tr>
  <tr bgcolor=#33ffcc>
    <td valign=top>Your email address</td>
    <td><input type=text size=60 name=email></td>
  </tr>
  <tr bgcolor=#33ffcc>
    <td valign=top>Your phone number</td>
    <td><input type=text size=60 name="field[Phone number]"></td>
  </tr>
  <tr bgcolor=#33ffcc>
    <td>Subject</td>
    <td><input type=text size=60 name=subject></td>
  </tr>
  <tr bgcolor=#33ffcc>
    <td valign=top>Message</td>
    <td><textarea name=message cols=60 rows=20 wrap=hard></textarea></td>
   </tr>
  <tr bgcolor=#33cc99>
  <td align=center colspan=2><input type=submit name=submit value="Send message"></td>
  </tr>
</table>
</form>

Configuring the behaviour of the mailback script

A plain text file called mailconf.txt should be present in the same directory as the HTML form (e.g. if the URL is:
http://www.mywebsite.com/talk/mailus.html
then the mailconf.txt file should be able to accessed as:
http://www.mywebsite.com/talk/mailconf.txt

The format of the file is simply a number of separate lines which contain a setting name and value separated by an equals sign. Spaces at the start or end of lines are ignored. Valid settings are listed in the table below (all other options will be ignored):

emailThe email address to send all messages to. You may specify multiple addresses by separating them with commas.
successA URL to go to if the mail is sent successfully (e.g. a page that says that the mail has been sent).
returnIf a value for success is not defined, this is a URL to return to after the visitor has been notified about the successful sending (e.g. a main index page)
noemailA URL to go to if the visitor does not specify an email address. If this is specified in the settings file, but no value is given (i.e. simply noemail=), then the message will still be sent. This could be useful if visitors to your site might not have email addresses and you have alternative methods of contacting them (e.g. your form asks for a phone number)
nomessageA URL to go to if no message is typed. If this is specified in the settings file, but no value is given (i.e. simply nomessage=), then the message will still be sent. This could be useful to simply collect addresses, e.g. for a mailing list.
copysenderIf set to "yes", then the sender will also get a copy of the mail sent to them
requiredSet to a comma-separated list of field names that are required (e.g. if you have field[phone] in your phone and want to ensure that a value is entered, put required=phone in your configuration file.
bgcolor, fgcolour, link, fontThese four options, if set, configure the background colour, text colour, link colour and font (respectively) on the error page returned if required fields aren't completed. They allow you to blend in with your site colour scheme.

Points to note:

  • All the form variables in the format field[description] (as described above) will be dealt with automatically, i.e. you do not need to add any extra options in you mailconf.txt file.
  • All URLs that don't begin with http:// will be assumed to be relative to the page holding the form.

All values are optional except for email. Therefore a minimal file would be:

email=me@mywebsite.com
However, you will probably want to personalise the mail handling by specifying your own pages to go to upon success or failure, e.g.
email = me@mywebsite.com
success = http://www.mywebsite.com/talk/thanks.html
noemail = noemail.html
nomessage = 
© Copyright Precedence Technologies 1999-2024
Time elapsed:0.018