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 Rapid Cloud Network and tweak it a bit to suit your requirements.
Sample Script
#!/usr/bin/perl
print "Content-type: text/html\n\n";
#
$title='Perl Mail demo';
$to='TO_Email';
$from= 'some-name@yourdomain.com';
$subject='perl mail';
open(MAIL, "|/usr/sbin/sendmail -t");
## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message
mail body text here\n";
close(MAIL);
print "<html><head><title>$title</title></head>\n<body>\n\n";
print "<h1>$title</h1><p>A message has been sent from $from to $to</p></body></html>";
#
-
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 code 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="xyz@yourdomain.com">
<input type="hidden" name="email" value="some-name@yourdomain.com">
<input type="hidden" name="realname" value="Feedback Form">
<input type="hidden" name="subject" value="Feedback Form">
<input type=hidden name="redirect" value="https://yourdomain.com/file.htm">
Below is the explanation about the variables in the code:
-
recipient: This would be 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 email field to any email address on the domain name, on which you are incorporating this script. For example, if you are deploying this script on yourdomain.com, then you would define the From email address as some-name@yourdomain.com. This email address need not be existing on the Mail Server of yourdomain.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@yourdomain.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 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 YourDomain.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.
In an attempt to keep a check on abuse from Rapid Cloud Network's Hosting Servers, the following conditions have been set for mail scripts on Rapid Cloud Network's Linux Hosting Servers:
-
The domain name in either the To or the From email address used in the script should be your domain name hosted with Rapid Cloud Network.
Example: yourdomain.com is hosted with Rapid Cloud Network and yourotherdomain1.com and yourotherdomain2.com are hosted with some other hosting provider.
-
The mail will be sent if
-
the From email address is abc@yourdomain.com and the To email address is xyz@yourotherdomain1.com,
OR
-
the From email address is abc@yourotherdomain1.com and the To email address is xyz@yourdomain.com.
-
-
The mail will not be sent if the From email address is abc@yourotherdomain1.com and the To email address is xyz@yourotherdomain2.com.
-
-
For mail scripts with the From email address as <user>@<server_hostname>, the To email address compulsorily should be an email address on your domain name hosted with Rapid Cloud Network.
Example: yourdomain.com is hosted with Rapid Cloud Network with parent user yourdo & server name cp-00.webhostbox.net and yourotherdomain1.com is hosted with some other hosting provider.
With the From email address as yourdo@cp-00.webhostbox.net:
-
The mail will be sent if the To email address is abc@yourdomain.com.
-
The mail will not be sent if the To email address is xyz@yourotherdomain1.com.
-