Skip to content

Instantly share code, notes, and snippets.

@tonyvu2014
Created July 20, 2015 11:58
Show Gist options
  • Save tonyvu2014/0b87d1580218dfd8b736 to your computer and use it in GitHub Desktop.
Save tonyvu2014/0b87d1580218dfd8b736 to your computer and use it in GitHub Desktop.
A perl cgi script to collect and send plain feedback to a list of site admin emails. This script can be used for contact us form, just need to ensure that the form fields match the param names in the script and update the corresponding email addresses. CGI.pm module is required on the server.
#!/usr/bin/perl
use CGI;
# Create a CGI.pm object
my $cgi = new CGI;
# Get the form data
my $email_address = $cgi->param('email');
my $feedback = $cgi->param('message');
my $name = $cgi->param('name');
my $contact = $cgi->param('contact');
my $company= $cgi->param('company');
my $subject = $cgi->param('subject');
# Email the form data
open ( MAIL, "| /usr/lib/sendmail -t" );
print MAIL "From: $email_address\n";
print MAIL "To: tonyvu2008\@gmail.com\n";
print MAIL "CC: dinhthe.vu\@tangs.net\n";
print MAIL "BCC: someone\@yahoo.com\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Name: $name\nContact: $contact\nCompany: $company\n\n";
print MAIL "$feedback\n";
print MAIL "\n.\n";
close ( MAIL );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment