Perl-based Form Mail (Feedback) Script

 Perl-based Form Mail (Feedback) Script

Using a Perl script you may accept feedback from your website visitors and get the results emailed to you. You can use the sample script provided by DOMAIN INDIA and tweak it a bit to suit your requirements.

Sample Script

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
unless(open (MAIL, "|/usr/sbin/sendmail -t"))
{
print "error.\n";
warn "Error starting sendmail: $!";
}
else
{
print MAIL "From: user\@domainname.com\n";
print MAIL "To: user\@domainname.com\n";
print MAIL "Subject: Mail from Enquiry Form\n\n";
print MAIL "Enquiry Form Details";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";
}
print "Content-type: text/plain\n\n";
 
IMPORTANT

    * The .pl file containing the script needs to be uploaded to your web server in ASCII mode only.
      
    * The .pl file needs to have execute permissions for the normal web user. For example, the .pl file can have permissions 755 or 765.

 

Sample HTML Feedback Form

 The following lines needs to be added in the form which connects to the above script:

<form action="cgi-bin/script.pl" method="POST">
<input type="hidden" name="recipient" value="user@domainname.com">
<input type="hidden" name="email" value="user@domainname.com">
<input type="hidden" name="realname" value="Feedback Form">
<input type="hidden" name="subject" value="Feedback Form">
<input type=hidden name="redirect" value="http://domanname.com/file.htm">

Following is the explanation about the above mentioned variables:

    * recipient - Here you need to specify the Email address, where the email containing the data submitted through the form, needs to be delivered.
      
    * email - You would need to change the Email address in the field email to any Email address on the domain name, on which you are incorporating this script. For example, if you are deploying this script on your Domain Name abc.com, then you would define the From Email address as some-name@abc.com. This Email address need not be existing on the Mail Server of abc.com, however, the domain name in the email field has to be yours. This implies, that you may use an Email address such as Do_Not_reply@abc.com. This email address will appear as the From email address in the email sent by the script.
      
    * realname - The value here indicates the name mentioned in the From section of the email, that will be sent to the email address, upon submission of this form. This can be modified as per your requirement.
      
    * subject - The value in this field can be changed to indicate an appropriate subject for the mail to be sent. For example, you may set this as YourDomainName.com Feedback Form or any other subject that would allow you to uniquely identify from which form on your website this data has been received.
      
    * redirect - Once the visitor provides feedback, he/she can then be redirected to another page on your website. In order to achieve this, you need to mention the path to the HTML file in the redirect field. Alternately, you can display a message to the visitor thanking him/her for the feedback. Such messages can be displayed in a new page like thanks.htm. Such a page can also contain other information as deemed necessary.

Was this answer helpful?

 Print this Article

Also Read

How to move Wordpress from one URL to another URL

Changing URLs on Wordpress is unlike other scripts in which you would have a configuration file...

How Pirated Themes Harm your site?

How Pirated Themes Harm your site? Nulled or pirated themes may contain malicious codes. Some...

Optimizing WordPress

Wordpress is currently one of the most popular blogging/CMS applications. Here are some ideas for...

Security Checklist/You have been hacked or defaced

Basic Site Security Checklist Summary By design our servers are secure. The security level...

How to change permissions of a file