Step 5: Format the Email Message (Optional)
The MailTo CGI provides a default format for the e-mail message containing the form results. You can customize the format of this message by creating a template and referencing the template in your form with a hidden field.
Note: The email template only formats the email message. It can NOT be used to send the information to additional people.
Follow these steps to create an email message template:
- Create a text file named with the extension ".txt". To create the text file you can use a web authoring tool or a text editor (e.g., Notepad on Windows or TextEdit on Macintosh).
- The body of the text file should be a complete email message that includes all the headers except the date. In other words, you should include the "To", "From", "CC", and "Subject" information. If you want to use any of the information submitted in the form, you need to use a variable named exactly the same as the field in your form. Remember, field name's are case sensitive. The variable has the format:
Where VariableName is the name of the field in your form.
An e-mail template might appear as follows:
Subject: Form Results
%Name used the example form.
- After you've created the .txt file, you need to reference the email template in your form.
Add the hidden field, "EmailForm" with the value set to the path of the email message template. Make sure you add the line after the <form> tag but before the </form> tag.
Depending on where you are publishing your pages (www.cmu.edu or www.andrew.cmu.edu), add the line in one of the following formats:
- If you are using the Andrew Web publishing system to publish on www.cmu.edu enter the line as follows:
<input name="EmailForm" type="hidden" value="http://www.cmu.edu/url/email-template.txt" />
Where url is your web site address and email-template.txt is the name of the email message template file.
- If you are publishing on www.andrew.cmu.edu, enter the line as follows:
<input name="EmailForm" type="hidden" value="http://www.cmu.edu/user/userid/email-template.txt" />
Where userid is your Andrew user ID and email-template.txt is the name of the email message template file.