View Full Version : Postcard Script

07-27-2002, 05:38 PM
Okay. I found a really good program for this, but I don't know how to set it all up, because it is all perl codes (I am clueless with most of this stuff), and my browser doesn't have the correct plugins.

Now I need script that will alow a visiter to send a postcard to a friend. Preferibly sending it all as an email, so it doesn't take up room in my account, waiting for someone to see it.

Thanks in advance!

07-27-2002, 08:31 PM
this is a script that I have written for a project of mine.
You can use it but please keep my comment at the top of the file and comment any change you'll make with your name.

#!/usr/bin/perl -w

# name: submit_suggestions.cgi
# author: Valentina Giorcelli
# descr: this program will take two parameters from the online form:
# the Subject line and the Comment felds. They are mandatory.
# The value of these fields will be anonymously emailed to the
# address specified in the variable $to. It will use the
# /usr/lib/sendmail
# Script was borrowed and adapted from "Perl and CGI for the
# World Wide Web", author Elizabeth Castro pag. 265
# version: 1.4 LAST MODIFIED: July 02, 2002
# this script can be used for free as long as this comment appears at the top

use strict;
#use warnings;
use CGI ":standard";

sub print_page;

# change the following line with the proper destination email address
my $to = "somebody\@somewhere.com"; #change this with the destination email address
#my $cc = "somebody\@somewhere.com"; # to copy the email so somebody else
my ($from, $subject, $suggestion);
my $message = ""; # this will hold the value of the code to be printed at the end of the script

if ((param('subject') ne "") && (param('suggestion') ne "") && ($from ne "") ) {
$from = param('from');
$subject = param('subject');
$suggestion = param('suggestion');

# check with your provider where is the sendmail program or issue a "locate sendmail" or a "whereis sendmail"
open (MAIL, "| /usr/lib/sendmail -t") or die "submit_suggestion.cgi: cannot send email: $!\n";

print MAIL "To: $to\n";
# print MAIL "Cc: $cc\n";
print MAIL "Subject: $subject\n";
print MAIL "$suggestion\n";

close (MAIL);

$message .= "Thank you <b>$from</b> for your suggestion!";
if (param('subject') eq "") {
$message .= "The <b>subject</b> field is mandatory<br>";
if (param('suggestion') eq "") {
$message .= "The <b>suggestion</b> field is mandatory<br>";
if (param('form') eq "") {
$message .= "The <b>from</b> field is mandatory<br>";
$message .= "<br>Press the back button on the browser or click <a href=javascript:history.go(-1)> [ here ]</a> and fix the errors!!<br>";
$message = " <br><font color=red> You need to be logged in to be able to access this feature<font><br>";

print header("text/html");

#--------------------------- SUB --------------------------------
sub print_page{

print <<"thanx";


The fields in the HTML form that call this .cgi will have to have the same name of the partameters used here
Hope this helps :D