B
Bob
I am not a code type guy, and the code below was given to me it works
but what I would like to do is put in some sort of email address
validation as I am not a coder I need as much help as I can get and
any help would be better than none.
#!/bin/perl
# ------------------------------------------------------------
# Form-mail.pl
#
# Form-mail provides a mechanism by which users of a World-
# Wide Web browser may submit comments to the webmasters
# (or anyone else) at a site. It should be compatible with
# any CGI-compatible HTTP server.
#
# ------------------------------------------------------------
# ------------------------------------------------------------
# Define fairly-constants
# This should be set to the username or alias that runs your
# WWW server.
$recipient = '(e-mail address removed)';
# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = '(e-mail address removed)';
# This should be set to the URL of your home page, or wherever
# you wish users to return.
$homepage = 'http://www.looploon.com/loon/welcome.html';
# This should match the mail program on your system.
$mailprog = '/usr/lib/sendmail';
# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";
# Print a title and initial heading
print "<Head><Title>Thank you</Title></Head>";
print "<Body><H1>Thank you</H1>";
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value<P>";
$FORM{$name} = $value;
}
# If the comments are blank, then give a "blank form" response
&blank_response1 unless $FORM{'realname'};
# If the comments are blank, then give a "blank form" response
&blank_response2 unless $FORM{'mnumber'};
# If the comments are blank, then give a "blank form" response
&blank_response3 unless $FORM{'emailaddress'};
# Header line in the auto-reply message
$Header = "LOOPLOON";
# Subject of the e-mail autoreply to the submitter
$Subject = "Thanks for Your Message!";
# Your signature lines the end of the autoreply e-mail
$Signature1 = "Bob Franklin (LoopLoon Web Master)";
$Signature2 = "www.LoopLoon.com";
&GetDate;
&SendAutoReply;
# Now send mail to $recipient
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $FORM{'emailaddress'} ($FORM{'realname'})\n";
print MAIL "Subject: LoopLoon Latest News (Forms submission)\n\n";
print MAIL "Full Name: $FORM{'realname'}\n\n";
print MAIL "Membership Number: $FORM{'mnumber'}\n\n";
print MAIL "Email Address: $FORM{'emailaddress'}\n\n";
print MAIL "Action: $FORM{'action'}\n\n";
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
#print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);
# _________________________________________________________
sub SendAutoReply {
open (MAIL,"|$mailprog -t");
#open (MAIL,"|$mailprog -t $recipient");
#open (MAIL,"|$mailprog -t $FORM{'emailaddress'}");
print MAIL "To: $FORM{'emailaddress'}\n";
print MAIL "From: $YourEmail\n";
print MAIL "Subject: LoopLoon Latest News (Subscription
Confirmation)\n\n";
print MAIL "$Header\n\n";
print MAIL "Subject: Subscription confirmation automated
response\n\n";
print MAIL "$Date\n";
print MAIL "$Subject\n\n";
print MAIL "You sent the following:\n";
print MAIL "==============================\n\n";
print MAIL "Full Name: $FORM{'realname'}\n";
print MAIL "Membership Number: $FORM{'mnumber'}\n";
print MAIL "Email Address: $FORM{'emailaddress'}\n";
print MAIL "Action: $FORM{'action'}\n\n";
print MAIL "MESSAGE: Please reply to this automated Subscription
Confirmation within 48 hours.\n";
print MAIL "To do so just send this Email back as a reply.\n\n";
print MAIL "==============================\n\n";
print MAIL "Best regards,\n\n";
print MAIL "$Signature1\n";
print MAIL "$Signature2\n\n";
close (MAIL);
}
# _________________________________________________________
sub GetDate {
@days =
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
@months =
('01','02','03','04','05','06','07','08','09','10','11','12');
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
$year = $year+1900;
$Date = "$days[$wday] $mday/$months[$mon]/$year";
}
# _________________________________________________________
# Make the person feel good for writing to us
print "Thank you for Subscribing to <I>LoopLoon Latest News</I>!<P>";
print "You will receive an automated Subscription Confirmation which
you must reply within 48 hours. ";
print "Return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
# ------------------------------------------------------------
# subroutine blank_response
sub blank_response1
{
print "Your Full Name appear to be blank, and thus were not sent
";
print "to our webmasters. Please re-enter your Full Name, or ";
print "return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
exit;
}
# ------------------------------------------------------------
# subroutine blank_response
sub blank_response2
{
print "Your Membership Number appear to be blank, and thus were
not sent ";
print "to our webmasters. Please re-enter your Membership Number,
or ";
print "return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
exit;
}
# ------------------------------------------------------------
# subroutine blank_response
sub blank_response3
{
print "Your Email Address appear to be blank, and thus were not
sent ";
print "to our webmasters. Please re-enter your Email Address, or
";
print "return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
exit;
}
Thanks
but what I would like to do is put in some sort of email address
validation as I am not a coder I need as much help as I can get and
any help would be better than none.
#!/bin/perl
# ------------------------------------------------------------
# Form-mail.pl
#
# Form-mail provides a mechanism by which users of a World-
# Wide Web browser may submit comments to the webmasters
# (or anyone else) at a site. It should be compatible with
# any CGI-compatible HTTP server.
#
# ------------------------------------------------------------
# ------------------------------------------------------------
# Define fairly-constants
# This should be set to the username or alias that runs your
# WWW server.
$recipient = '(e-mail address removed)';
# E-mail address to send intake form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @
$YourEmail = '(e-mail address removed)';
# This should be set to the URL of your home page, or wherever
# you wish users to return.
$homepage = 'http://www.looploon.com/loon/welcome.html';
# This should match the mail program on your system.
$mailprog = '/usr/lib/sendmail';
# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";
# Print a title and initial heading
print "<Head><Title>Thank you</Title></Head>";
print "<Body><H1>Thank you</H1>";
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value<P>";
$FORM{$name} = $value;
}
# If the comments are blank, then give a "blank form" response
&blank_response1 unless $FORM{'realname'};
# If the comments are blank, then give a "blank form" response
&blank_response2 unless $FORM{'mnumber'};
# If the comments are blank, then give a "blank form" response
&blank_response3 unless $FORM{'emailaddress'};
# Header line in the auto-reply message
$Header = "LOOPLOON";
# Subject of the e-mail autoreply to the submitter
$Subject = "Thanks for Your Message!";
# Your signature lines the end of the autoreply e-mail
$Signature1 = "Bob Franklin (LoopLoon Web Master)";
$Signature2 = "www.LoopLoon.com";
&GetDate;
&SendAutoReply;
# Now send mail to $recipient
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $FORM{'emailaddress'} ($FORM{'realname'})\n";
print MAIL "Subject: LoopLoon Latest News (Forms submission)\n\n";
print MAIL "Full Name: $FORM{'realname'}\n\n";
print MAIL "Membership Number: $FORM{'mnumber'}\n\n";
print MAIL "Email Address: $FORM{'emailaddress'}\n\n";
print MAIL "Action: $FORM{'action'}\n\n";
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
#print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);
# _________________________________________________________
sub SendAutoReply {
open (MAIL,"|$mailprog -t");
#open (MAIL,"|$mailprog -t $recipient");
#open (MAIL,"|$mailprog -t $FORM{'emailaddress'}");
print MAIL "To: $FORM{'emailaddress'}\n";
print MAIL "From: $YourEmail\n";
print MAIL "Subject: LoopLoon Latest News (Subscription
Confirmation)\n\n";
print MAIL "$Header\n\n";
print MAIL "Subject: Subscription confirmation automated
response\n\n";
print MAIL "$Date\n";
print MAIL "$Subject\n\n";
print MAIL "You sent the following:\n";
print MAIL "==============================\n\n";
print MAIL "Full Name: $FORM{'realname'}\n";
print MAIL "Membership Number: $FORM{'mnumber'}\n";
print MAIL "Email Address: $FORM{'emailaddress'}\n";
print MAIL "Action: $FORM{'action'}\n\n";
print MAIL "MESSAGE: Please reply to this automated Subscription
Confirmation within 48 hours.\n";
print MAIL "To do so just send this Email back as a reply.\n\n";
print MAIL "==============================\n\n";
print MAIL "Best regards,\n\n";
print MAIL "$Signature1\n";
print MAIL "$Signature2\n\n";
close (MAIL);
}
# _________________________________________________________
sub GetDate {
@days =
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
@months =
('01','02','03','04','05','06','07','08','09','10','11','12');
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
$year = $year+1900;
$Date = "$days[$wday] $mday/$months[$mon]/$year";
}
# _________________________________________________________
# Make the person feel good for writing to us
print "Thank you for Subscribing to <I>LoopLoon Latest News</I>!<P>";
print "You will receive an automated Subscription Confirmation which
you must reply within 48 hours. ";
print "Return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
# ------------------------------------------------------------
# subroutine blank_response
sub blank_response1
{
print "Your Full Name appear to be blank, and thus were not sent
";
print "to our webmasters. Please re-enter your Full Name, or ";
print "return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
exit;
}
# ------------------------------------------------------------
# subroutine blank_response
sub blank_response2
{
print "Your Membership Number appear to be blank, and thus were
not sent ";
print "to our webmasters. Please re-enter your Membership Number,
or ";
print "return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
exit;
}
# ------------------------------------------------------------
# subroutine blank_response
sub blank_response3
{
print "Your Email Address appear to be blank, and thus were not
sent ";
print "to our webmasters. Please re-enter your Email Address, or
";
print "return to our <A HREF=\"$homepage\">home page</A>, if you
want.<P>";
exit;
}
Thanks