Sendmail Instructions
 

Below are instructions along with example HTML codes associated with the Sendmail script. To be sure everything works right follow all of the instructions in order.

Code :: Locations

Open up Sendmail.cgi in a text editor such as notepad or wordpad but not Microsoft Word.

If you script shows an error message such as 'Internal Server Error' it is most-likely because your locations are wrong or you haven't chmodded it correctly. Contact your hosting provider and ask where perl is located. Then change /usr/bin/perl to the correct location.

#!/usr/bin/perl

Also ask where sendmail is located and change /usr/sbin/sendmail to the correct location.

$mailprog = '/usr/sbin/sendmail';

If it still does not work contact us via the support page and we will help you fix it.


Code :: Security

This step is required for everything to work. Look for the below code and change your-site.com and www.your-site.com to your actual domain (website) name. One with the www. and one without it.

@alowed_sites = ("your-site.com","www.your-site.com");

You can add as many sites as you want like so.

@alowed_sites = ("your-site.com","www.your-site.com","your-site2.com","www.your-site2.com");


cgi-bin and ASCII Mode

This step is required for the script to work. Before uploading make a folder named cgi-bin. The URL should look like this (http://your-site.com/cgi-bin/). Then upload sendmail.cgi into the cgi bin folder.

When uploading the .cgi files make sure you have ASCII mode selected in your FTP software. Dreamweaver's FTP software should do this automatically.

cgi-bin may not be the correct folder name (Most likely it is correct). If the script doesn't work after you complete these instructions contact your hosting provider and ask where to put perl/cgi scripts on your server.


CHMOD 755

This step is required for the script to work on your server. After uploading the script you need to CHMOD it to 755. In most FTP software's this can be done by right clicking the script on your server and selecting Properties or Options. From there just look for the word CHMOD.


Code :: Beginning the form

This code is required for everything to work. If the Sendmail script is not in the same directory (folder) as the page with the form on it (ie: contact page) then change the action to path/to/sendmail.cgi.

<form name="sendmail" method="post" action="sendmail.cgi">


Code :: Example text field

This is an example code for a text field. Change 'something' to what ever you want, but it helps to name it something relevant to what you want the visitor to type in. Never put spaces, camas, periods, ect in the name. Use an underscore(_) instead.

<input type="text" name="something">

It is also important to label your text fields so visitors know what to put in each one like so.

Name: <input type="text" name="name">

Don't label the fields that are hidden (type="hidden") though. For the email message use this.

<textarea name="message" cols="35" rows="5"></textarea>


Asking for an email address

If you are asking for and requiring an email address make sure name is set to email (name="email"). That way the script will make sure it is valid. If it is not it will redirect them to an error page. If you do not require an email address set the name to any thing but 'emai'l.


Code :: Email subject

If you want to specify an unique subject title for emails sent through the sendmail script try this.

<input type="hidden" name="subject" value="'email_subject">

If you want your visitors to choose the subject use this code.

<input type="text" name="subject" value="'email_subject">

Replace 'email_subject' with what you want the subject of every email to be.

The default subject is 'WWW FORM SUBMISSION'.


Code :: Recipient

This code is required for the email to be delivered. Replace 'email_address' with the full email address you want the email sent to. If type="hidden" then this field will be invisible to visitors. Just put all of the hidden fields after the submit button, but make sure they are all before </form>.

<input type="hidden" name="recipient" value="email_address">


Code :: Required fields

If You are requiring information you need to include this code.

<input type="hidden" name="required" value="field1,field2">

Replace 'field1,field2' with the names of the fields that you want to require. Separate each name by a comma. Only enter fields in which the user can type something in.


Code
:: Redirect

If all of the required fields are filled in the script will redirect users to the URL you specify. Replace 'URL' with the URL you want them sent to. (ie: thanks.html or path/to/thanks.html) If you don't include this code your users will be sent here.

<input type="hidden" name="redirect" value="URL">


Code :: Missing fields redirect

If all or the required fields are NOT filled in the script will redirect users to the URL you specify. Replace 'URL' with the URL you want them sent to. (ie: sorry.html or path/to/sorry.html) If you don't include this code your users will be sent here.

<input type="hidden" name="missing_fields_redirect" value="URL">


Code :: Sorting the email contents

Here is what your emails will look like:

name = persons name
email = persons email address
message = The massage the user typed in. The massage the user typed in. The massage the user typed in.

By default your email data will be listed in a random order. If you want the data to be sorted alphabetically by name of field then use this code.

<input type="hidden" name="sort" value="abc">

If you want to set your own order the use this code.

<input type="hidden" name="sort" value="field1,field2">

Replace 'field1,field2' with the names of the fields where the user can type something in. Separate each name by a comma and list them in the order you want them to appear.


Code :: Ending the form

After you have added all the above code finish your form by adding a submit button to send the data to the script.

<input type="submit" name="submit" value="Submit">

If you want your users to be able reset all or the fields to default and start over add this code.

<input type="reset" name="reset" value="Reset">

And then finish the form with the closing tag.

</form>