simple_cgi_email - A simple script to send email from an HTML form submission. simple_cgi_email is meant to provide a quick-n-dirty way to send email from an HTML form. Its output is fairly unpleasant to look at, certainly not suitable for clients or anyone else who cares about the format of their emails, but it's perfect for small feedback forms, contact forms, registration forms, etc. simple_cgi_email was written by Sam Clippinger (samc@lookandfeel.com) and is based on LAFmessage, a generic messaging library produced by lookandfeel new media. simple_cgi_email and LAFmessage are both available from lookandfeel's free software site at: http://freesoftware.lookandfeel.com/ INSTALLATION ============ simple_cgi_email compiles and runs on Win32 and Linux. Compiling on Win32 requires Microsoft Visual C++ 6.0 or higher. The DSP file should load the entire project. After adjusting the output paths to suit your environment, the project should compile without errors (the default output file is E:\Projects\Output\simple_cgi_email.exe). Compiling on Linux requires GNU g++. Simply running "make" should produce an executable in the project directory named "simple_cgi_email". If you get a million syntax errors, it's possible that the source files were last saved in DOS format (lines end in CRLF) instead of Unix format (lines end in LF). To correct this, run "make reformat", then "make" again. To remove all of the intermediate and output files, run "make clean". On both platforms, you must copy the executable file to a directory from which the web server can run it as a CGI script. USAGE ===== simple_cgi_email expects at least five parameters in the query string. They are: from_address - The address the message should appear to come from. smtp_server - The name or IP address of the SMTP server to use. success_file - The HTML file to display to the user upon success. subject - The subject of the message. to_address - The address the message should be delivered to. simple_cgi_email will optionally accept four more parameters in the query string. They are: failure_file - The HTML file to display to the user upon failure. from_name - The name the message should appear to come from. smtp_port - The port number to use on the SMTP server. Defaults to 25. to_name - The name the message should be delivered to. All other parameters passed through the query string will be ignored. All variables passed through POSTed content will be used to create the message body. An example HTML file that uses simple_cgi_email follows: ............................................................
FOO! BAR!
............................................................ When the form is loaded and the button is clicked, the following email would be generated (some headers omitted for clarity): ............................................................ To: Mr. Bar From: Mr. Foo Subject: You've been FOOed! REMOTE_ADDR: 0.0.0.0 HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530 HTTP_REFERER: http://www.foo.com/fooform.html REQUEST_METHOD: POST SERVER_NAME: www.foo.com SCRIPT_NAME: /cgi-bin/simple_cgi_email QUERY_STRING: from_address=foo@foo.com&smtp_server=mail.foo.com&success_file=success.html&subject=You've+been+FOOed!&to_address=bar@bar.com&to_name=Mr.+Bar&from_name=Mr.+Foo&smtp_port=25&failure_file=failure.html field_one: field one content field_two: field two content foo_or_bar: FOO! submitbutton: Click this! ............................................................ Note that the format of the generated email message cannot be dictated by the form, nor can simple_cgi_email send to multiple addresses -- those restrictions are what make it "simple". If simple_cgi_email cannot generate or send the message for any reason, it will display the contents of the file given in the parameter failure_file and display an error message as an HTML comment at the top of the output. If no failure_file parameter is given, the error message will be displayed.