#!/usr/bin/perl # # Perl email CGI program for my web site... # # Author: Matthew William Coan # Date: Wed Dec 10 15:57:51 EST 2008 # use CGI::Lite; print "Content-type: text/html\r\n\r\n"; flush; my $cgi = new CGI::Lite; my $q = $cgi->parse_form_data('POST'); $error = ""; $name = $q->{"name"}; $email = $q->{"email"}; $url = $q->{"URL"}; $message = $q->{"message"}; if($name eq "") { $error .= "Please enter your name.
"; } if($email eq "") { $error .= "Please enter your email address.
"; } elsif(!($email =~ /[\@]/)) { $error .= "Please enter your correct and compleat email address.
"; } if($message eq "") { $error .= "Please enter your message.
"; } if($error eq "") { # send email to me # $sendmail = "/usr/sbin/sendmail -t"; $my_email = "mcoan\@localhost"; # print "EMAIL: ",$my_email,"
\n"; # open(SENDMAIL, "|$sendmail") or die "Cannot open sendmail: $!"; # print SENDMAIL "From: mcoan\@slack.net\n"; print SENDMAIL "To: $my_email\n"; print SENDMAIL "Subject: Web Site From: Abode of Matthew W. Coan\n\n"; # print SENDMAIL "Name: $name\n\n"; print SENDMAIL "Email: $email\n\n"; print SENDMAIL "URL: $url\n\n"; print SENDMAIL "Message:\n$message\n"; # close(SENDMAIL) or die("unable to send mail..."); # write data to the end of the log file # $email_log_file = "/home/mcoan/email_log.txt"; open(OUTFILE, ">>$email_log_file") or die "Cannot open email log file..."; $email =~ s/[\"]/\"\"/g; $name =~ s/[\"]/\"\"/g; $url =~ s/[\"]/\"\"/g; $message =~ s/[\"]/\"\"/g; $message =~ s/[\r]//g; $message =~ s/[\n]/ /g; print OUTFILE "\"$email\",\"$name\",\"$url\",\"$message\"\n"; close(OUTFILE) or die "unable to close log file..."; print < Matthew W. Coans Abode - Email Form: Thank you...

Matthew W. Coan's Abode - Email Form: Thank you...




Back to the main page...

END_OF_HTML flush; } else { print < Matthew W. Coans Abode - Email Form: Error...

Matthew W. Coan's Abode - Email Form: Error...


$error







Back to the main page...

END_OF_HTML flush; } exit 0;