#!usr/bin/perl
use Socket;
use MIME::Entity;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();$pid=$$;
local %form = &get_form_data;
$File = "P$hour$min$sec$year$yday-$pid.htm"; #change this to your data file
&writefile;
&sendemail;
print "Content-Type: text/html\n\n";
print "<html><head><title>Thanks for your interest</title>\n</head><body><font face=\"Verdana\" size=\"2\" color=\"#008000\">
We thank you for your query & it has been queued<br>
We will be in touch at the earliest convenience<br>
Please allow up to 3 working days for a reply<br><br>
Thank you for your query<hr>
Click on the menu to the left to navigate your way around the site,</body>";
&sendemail;
sub sendemail {
local($print_config,$key,$sort_order,$sorted_field,$env_report);
$mailprog = '/usr/sbin/sendmail';
$auto_type = 'text/plain';
$auto_encoding = 'base64';
$auto_body = 'body.txt';
$message_type = 'multipart/mixed';
$log_or_email = 'B';
$email_log = 'automail_lite.log';
$Body="Guess what";
$top = build MIME::Entity Type => $message_type,
From => "webserver\@yourdomain.com",
To => "user\@mailbox.com",
Subject => "New query from webserver";
attach $top Data=> $Body;
attach $top Path => "$File",Type => $auto_type,Encoding => $auto_encoding;
open MAIL, "|$mailprog -t -i" or die "open: $!";
$top->print(\*MAIL);
close MAIL;
my @file ="$File"; #comment these out if you go ahead with your file
unlink @file; # and this one
}
sub writefile {
open TXT, ">$File";
print TXT "<html>\n";
print TXT "<body>\n";
print TXT "<table width=\"60%\">\n";
print TXT " <tr>\n";
print TXT " <td>Name:</td><td>$form{'name'}</td>\n";
print TXT " </tr>\n";
print TXT " <tr>\n";
print TXT " <td>Telephone</td><td>$form{'tel'}</td>\n";
print TXT " </tr>";
print TXT " <tr>";
print TXT " <td>email</td><td>$form{'fax'}</td>\n";
print TXT " </tr>\n";
print TXT " <tr>";
print TXT " <td>email</td><td>$form{'email'}</td>\n";
print TXT " </tr>\n";
print TXT " <tr>";
print TXT " <td>email</td><td>$form{'query'}</td>\n";
print TXT " </tr>\n";
print TXT " <tr>\n";
print TXT " <td>interest</td><td>$form{'interest'}</td>\n";
print TXT " </tr>\n";
print TXT "</table>\n";
print TXT "</body>\n";
print TXT "</html>\n";
}
sub get_form_data {
my $temp;
my $buffer;
my @data;
my $count = 0;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
foreach $temp (split(/&|=/,$buffer)) {
$temp =~ tr/+/ /;
$temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$temp =~ s/[\r\n]/ /g;
push @data, $temp;
}
foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
$temp =~ tr/+/ /;
$temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$temp =~ s/[\r\n]/ /g;
push @data, $temp;
}
return @data;
}