##############################################################################
# MailFile                      Version 1.5.1 README                         #
# By Command-O Software                                                      #
# http://www.command-o.com                                                   #
#                                                                            #
# Based on:                                                                  #
# FormMail                      Version 1.5                                  #
# Copyright 1996 Matt Wright    mattw@misha.net                              #
# Created 6/9/95                Last Modified 2/5/96                         #
# Scripts Archive at:           http://www.worldwidemart.com/scripts/        #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
#                                                                            #
# FormMail may be used and modified free of charge by anyone so long as this #
# copyright notice and the comments above remain intact.  By using this      #
# code you agree to indemnify Matthew M. Wright from any liability that      #
# might arise from it's use.                                                 #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
##############################################################################
The first line of the script must tell the server where Perl is on the 
server. If you don't know use the command "whereis perl" ata Unix Prompt.
The first line will be something like this:
#! /usr/local/bin/perl
or maybe this:
#! /usr/bin/perl

Then you must define the variables in the script. This has many more to 
set than Matt's FormMail script, but you shouldn't have much of a problem 
with this.

$mailprog = '/usr/lib/sendmail';
The location of your sendmail program goes here. If you don't know you 
can use the command "whereis sendmail" at a Unix prompt.

$newurl = 'http://www.command-o.com';
If the script runs properly and they entered sufficient information this 
is the url where people requesting files will be sent upon completion of 
the script running.

$fromaddr = 'info@command-o.com';
This is the e-mail address from which the files will be sent. The script 
will also send e-mail to this address telling you what files the person 
requested as well as any comments the person included with their request.


$organization = 'Command-O Software';
This is simply whatever organization is sending the files. Your company 
or whatever.

$fromname = 'Command-O Software';
This is the name of the person (or whatever) the files are being sent from.

$filebase = '/usr/local/etc/httpd/htdocs/products/freeware';
This is the base path to all files you want sent. There must be no slash 
at the end of this one. If the files are coming from multiple directories 
you must show this in the filename part of the form such as "chat/chat.tar" 

$form_letter = "";
This is the file you want sent out with every request for files (it will be 
sent as a seperate message. Leave blank if you don't want one. This
must follow the same rules set by $filebase (if it's in a sub directory 
of the $filebase that directory must also be named for $form_letter. For 
instance if the form letter is in the letters directory in the base 
directory this variable should be set to "letters/form_letter.txt" or 
whatever.

@referers = ("www.command-o.com","command-o.com");
@referers allows forms to be located only on servers which are defined
in this field.  This fixes a security hole in the last version which
allowed anyone on any server to use your FormMail script.

That's it for setting variables within the script. Now you must set the 
permissions for the script. To do this just type "chmod 755 mailfile.cgi" 
at a Unix prompt. Substitute whatever you named the script for mailfile.cgi

Now to use this script you must include a form in an html file which 
calls the script. Here is a sample:

<form method=post action="mailfile.cgi">
<input type=checkbox name="filename" value="chatpro/chatpro.pl">ChatPro.pl<br>
<input type=checkbox name="filename" value="chatpro/chatpro.tar">ChatPro.tar<br>
Mail: <input type=text name="email" size=40><br>
Name: <input type=text name="realname"><br>
Comments: <textarea rows=4 cols=40 name="comments"></textarea>
<input type=submit value="Send It">
</form>

And here is an explanation of the html:

<form method=post action="mailfile.cgi">
The action must be set to the url of the script. In this case the page 
with the html is in the smae directory as the script, so I only needed to 
pu the name of the script in.

<input type=checkbox name="filename" value="chatpro/chatpro.pl">ChatPro.pl<br>
<input type=checkbox name="filename" value="chatpro/chatpro.tar">ChatPro.tar<br>
These are the files the person is requesting. In this case they are 
checkboxes on the form. All the inputs for files on the form should have 
name set to "filename and value set to the actual name of the file. In 
this case I have them in a subdirectory of my $base_dir so I covered that 
here. If a person doesn't request any files they will be told that they 
need to choose a file and try again.

Mail: <input type=text name="email" size=40><br>
This is where the person requesting the files enters their e-mail 
address. If they enter an improperly formatted address or leave this 
blank they will be told they need to correct it and try again.

Name: <input type=text name="realname"><br>
This is the name of the person requesting the files. This field isn't 
required.

Comments: <textarea rows=4 cols=40 name="comments"></textarea>
This provides an area for the person requesting the files to send 
comments to the owner of the files (set with the $fromaddr variable). 
This field is not required.

<input type=submit value="Send It">
This is the submit button so they can send the form to the script.

</form>
This is the end of the form on the page.

This script is also able to automatically make a form listing every file 
in the $filebase directory. To do that make a link to the script with a 
QUERY_STRING of "archive", something like this:
<a href="http://yourdamin.com/cgi-bin/mailfile.pl?archive">

That's all there is to it. There is no limit to the number of files you 
can send someone so long as they follow the guidelines outlined above.

Version 1.5.1 added the archiving ability. It also now alerts someone 
when they request a non-existent file and sends mail to the script owner 
saying that file apparently doesn't exist.
