This simple Perl script allows the contents of a submitted web form to be emailed to a given address. Although there are other more sophisticated scripts that offer similar functionality, the main benefit of this one is that all the required mail header parameters are embedded in the script, rather than being picked up from the form, and hence provides a securer environment.
There are six variables that need setting up in the script to match local requirements:
- $from - the address of the sender that appears in the email.
- $to - the email address to which the contents of the form are to be sent.
- $subject - the text that is to appear on the subject line of the email.
- $error_url - the address of a web page to which the user is sent if errors are detected whilst processing the form.
- $return_url - the address of the web page to which the user is sent if the form has been processed successfully.
- $sendmail - the address of the sendmail program. This can vary from one server to another, and if the script doesn't work, you may need to take advice from your system manager.
To use this Perl script you should first copy it in your CGI BIN directory, giving it execute privileges (on a *nix system, this will require a CHMOD to #755). You should then reference the script in the action attribute of your form tag. e.g.
Download compressed software (1,471 bytes)