How do I add a c4.net Mail Form to my Website

All customers who host a Web site with c4.net, regardless of whether or not they have their own domain or take advantage of c4.net's free Web space, may use the c4.net mail form processor. The mail form processor takes a form submitted from your Web site and turns it into a piece of e-mail which will then be sent to your address. This can be used for contact forms and support forms.

Setting this up requires a basic knowledge in designing a Web site. Specifically, you will have to know how to create and edit HTML forms and upload those forms to your site. If you are not familiar with these techniques, c4.net staff can construct and implement one or more forms for you at our normal hourly rates.

If you are comfortable creating the form yourself, please review the following instructions. They contain a complete list of attributes which can be passed to the mail form processor by way of hidden form fields.

Creating the Form

To add a form to your site, you much include the basic form elements. These include <form> tags and a pointer to the mail form processor.

Example code:

                        <form
                            action="http://www.c4.net/Scripts/MailForm.cfm"
                            method="post">
                        
                        <!-- Place all your form fields and mail
                          -- form processor attributes here -->
                    
                        </form>
                    

For more examples, see the "Complete Examples" section towards the bottom of this page.

Mail Form Processor Attributes

The mail form processor requires certain information. Just as when you send a piece of e-mail you need to provide a "To" address and type a subject. Similarly, the mail form processor needs information to convert your form into a piece of e-mail. We call these attributes.

The following is a list of attributes which you can use to control the way the mail form processor functions. Include attributes between your <form> and </form> tags.

MailTo
The MailTo field stores the address to which you'd like the message containing the form submission sent. It must be a fully qualified e-mail address, including the domain name (e.g. surf@c4.net). If this attribute is not passed, the address postmaster@yourdomain.com will be used where "yourdomain.com" is the name of your domain.

Example code:

                        <input type="hidden"
                            name="MailTo" value="surf@c4.net">
                    

From
The From field corresponds to the From field in the e-mail message. It must be a fully qualified e-mail address, including the domain name (e.g. surf@c4.net). If this attribute is not passed, the address website@yourdomain.com will be used where "yourdomain.com" is the name of your domain.

Example code:

                        <input type="hidden"
                            name="From" value="surf@c4.net">
                    

ReplyTo
This attribute allows you to control the "reply-to" header of the outbound message. The "From" attribute is used by default.

Example code:

                        <input type="hidden"
                            name="ReplyTo" value="surf@c4.net">
                    

Subject
The Subject field corresponds to the Subject field in the e-mail message. If it is not provided, a generic subject line will be used.

Example code:

                        <input type="hidden"
                            name="Subject" value="Form Submission From Web Site">
                    

MailHost
This is the mail server that you wish to send mail through. The c4.net mail server will be used by default. If you wish to specify another mail server, you can do so using this field, but it should not be necessary for most situations.

Example code:

                        <input type="hidden"
                            name="MailHost" value="mailman.c4.net">
                    

Required
If you would like to ensure that the user provides information for several fields (i.e. force the user to provide their name and contact information), you can do so using the Required attribute. Specify those fields which you require in coma delimited list.

Example code:

                        <input type="hidden"
                            name="Required"
                            value="Name,Email,PhoneNumber">
                    

This example assumes you have three fields in your form, named "Name," "Email," and "PhoneNumber." The user will be forced to provide this information before successfully submitting the form. Please note, however, that the information is not validated to ensure that it is accurate.

OnSuccess
This is the location that you would like the user sent to after the form submission is successful. The default location is the home page of your Web site.

Example code:

                        <input type="hidden"
                            name="OnSuccess"
                            value="http://www.yourdomain.com/OnSuccess.htm">
                    

Please note that lines in examples that end in "..." have been wrapped. The dots should be removed, along with the following line break and any spaces.

OnFailure
This is the location that you would like the user sent to if the form submission is not successful (i.e. the user has not provided a required field). If this is not provided, the system will generate a generic error message, asking the user to click the back button on their browser and fill out all the fields on the form.

Example code:

                        <input type="hidden"
                            name="OnFailure"
                            value="http://www.yourdomain.com/OnFailure.htm">
                    

Template
This is the location of the template that you would like to use to format the message that is sent out. If a template is not specified, the mail form processor will "dump" all the form fields into the body of the message.

Example code:

                        <input type="hidden"
                            name="Template"
                            value="http://www.yourdomain.com/YourTemplate.txt">
                    

The template will be used as the basis for the message. The mail form processor will replace elements of the template with information the user submits. These elements must be formated with the specific form name enclosed in greater than/less than signs.

Example template code:

                        This is a form submission from the site.
                        
                        Name: <Name>
                        E-mail Address: <Email>
                        Comments: <Comments>
                    

This example assumes you have a form on your site with three fields. The fields are named "Name," "Email," and "Comments." The mail form processor will replace the corresponding items in the template, creating a message which looks something like this:

                        This is a form submission from the site.
                        
                        Name: John Smith
                        E-mail Address: JohnSmith99@c4.net
                        Comments: I like your Web site.
                    

MessageType
If your template contains HTML formatting, you can send the message in HTML format rather than plain text. To do so, set the MessageType attribute to "HTML." The default is "Text."

Example code:

                        <input type="hidden"
                            name="MessageType" value="HTML">
                    

SendAutoReply
If you would like the user to receive an auto reply via e-mail immediately upon completion of the form, you can do so using the SendAutoReply attribute. Set it to "Yes" to send an auto reply. The default is "No."

Example code:

                        <input type="hidden"
                            name="SendAutoReply" value="Yes">
                    

AutoReplyTemplate
This is similar to the "Template" attribute mentioned above except that this one is used for the auto reply message. Please see the description of the Template attribute for more information.

Example code:

                        <input type="hidden"
                            name="AutoReplyTemplate"
                            value="http://www.c4.net/Scripts/MailForm/...
                            PlainTextAutoReplyTemplate.txt">
                    

AutoReplyMessageType
If your auto reply template contains HTML formatting, you can send the message in HTML format rather than plain text. To do so, set the AutoReplyMessageType attribute to "HTML." The default is "Text."

Example code:

                        <input type="hidden"
                            name="AutoReplyMessageType" value="HTML">
                    

Referencing Another Field
If you would like to use the value of one field for another field as well, you can do so using the following trick. Set the value of your field to the name of the other field preceeded by a "~" character. So, for example, if you are converting a form which was used on a previous host and the form already has a field called "Email," you can use the value of that field for your "From" field.

Example code:

                        <input type="hidden"
                            name="From" value="~Email">
                    
                        Please provide your e-mail address:
                        <input type="Text" name="Email">
                    

Complete Example

You will need to modify the following example code slightly to make it work on your Web site. It should, however, give you a good starting point for creating a mail form.

Contact Form
This is a sample contact form which collects the bare minimum of information from the user and e-mails it to your address.

Example code:

                        <form
                            action="http://www.c4.net/Scripts/MailForm.cfm"
                            method="post">
                        
                            <input type="hidden"
                                name="From" value="~Email">
                            
                            <input type="hidden"
                                name="MailTo"
                                value="[your e-mail address here]">
                            
                            <input type="hidden"
                                name="Required"
                                value="Name,Email">
                            
                            Name:<br>
                            <input type="Text"
                                name="Name" size="40"><br>
                            <br>
                            Company:<br>
                            <input type="Text"
                                name="Company" size="40"><br>
                            <br>
                            E-mail Address:<br>
                            <input type="Text"
                                name="Email" size="40"><br>
                            <br>
                            Phone Number:<br>
                            <input type="Text"
                                name="PhoneNumber" size="40"><br>
                            <br>
                            Comments:<br>
                            <textarea name="Comments"
                                rows="6" cols="30"></textarea><br>
                            <br>
                            <input type="Submit"
                                value="Send Your Comments"><br>
                            
                        </form>
                    

If you would like to format your message with a template, add the following code to the example above.

                        <input type="hidden"
                            name="Template"
                            value="http://[Your Web Site Here]/Template.txt">
                    

Then, create a file called Template.txt following this example. Place the file on your Web site.

                        The following is a form submission from your Web site.
                        
                        Name: <Name>
                        Company: <Company>
                        E-mail Address: <Email>
                        Phone Number: <PhoneNumber>
                        Comments: <Comments>
                    
                        The following is a form submission from your Web site.
                        
                        Name: <Name>
                        Company: <Company>
                        E-mail Address: <Email>
                        Phone Number: <PhoneNumber>
                        Comments: <Comments>
                    

Contact Us

Privacy Policy    Copyright Policy

c4.net Internet Services
721 Main Street, Harwich, MA 02645 USA
+1 (508) 430-1776