CGI Email Script

by on April 9th, 2008

Sometimes we have to work with servers which do not support PHP or other programming languages other then CGI. And we know how much email facility is important for a website! So for this case here is the CGI emailing script which will send a detailed email.

This example uses three files.

HTML Form Page that contains path to cgi script and also a hidden mail field to which mail is to be sent.
Configuration File which contain email address and cgi script.
CGI e-Mail Script will also contain these lines which is path to sendmail and email.conf file path.

my $sendmail = “/usr/sbin/sendmail”;
my $emailConfPath = “/home/username/public_html/cgi-bin/email.conf”;

In emailconfpath username is user of server rest of thing will remain same and email.conf is the file name which is located in the cgi-bin.

Upload HTML in the root, conf and sendMail files in cgi-bin directory. Also keep CHMOD 755 to ensure keep it executable.

Download the Script

Download full example of CGI Mail Form