Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI Mail to form

Status
Not open for further replies.

Netwrkengeer

IS-IT--Management
Apr 4, 2001
184
US
Does anyone know where I can get a simple Mail to CGI form, or can someone post one. Thanks
 
#!/usr/local/bin/perl

###### SpyderForm v1.0 ######
## Created by Aaron Anderson ##
## sulfericacid@qwest.net ##
## website: ##
## Please read the readme file prior to installation. ##
## If you cannot find readme, dl a copy from my site! ##


use strict;

# Let's have some fun my'ing things, shall me?
my %form;
my $sendmail;
my $webmaster;
my $yourname;
my $thanks;

use CGI;
my $query = CGI->new;

print $query->header;

%form = %{$query->Vars};

##################### BEGIN EDITING THIS SECTION #############################
$sendmail = "/var/qmail/bin/qmail-inject";
$webmaster = 'sulfericacid@qwest.net';
( $thanks = <<'END_OF_THANKS' ) =~ s/^\s+//gm ;
Thank you for visiting my website! Things are always
changing so I hope you pop back again! If you asked
any questions, please allow upto 24 hours for a response.
END_OF_THANKS
$yourname = 'Aaron';

# $signame = 'Aaron Anderson\n';
# $sigurl = '#################### STOP EDITING FOR NOW #####################################

### Make sure things are being completed, die slackers!
if ($webmaster eq &quot;&quot;) {
print &quot;Webmaster, please include your email address!\n&quot;;
}
if ($form{'usermail'} eq &quot;&quot;) {
print &quot;Ok, buddy, how do you expect me to email you back if you FORGET to leave yoru email address?!?\n&quot;;
}
if ($form{'username'} eq &quot;&quot;) {
print &quot;Please click back and type in your name so I can spy on you!\n&quot;;
}
if ($form{'message'} eq &quot;&quot;) {
print &quot;Only a severe slacker would try to submit a form without leaving a message!\n&quot;;
}

# Mail to Webmaster
open (MAIL, '|-', &quot;$sendmail -t&quot;) or die $!;
print MAIL &quot;To: $webmaster\n&quot;;
print MAIL &quot;From: $form{'usermail'}\n&quot;;
print MAIL &quot;Subject: Insert subject here!\n\n&quot;;
print MAIL &quot;Name- $form{'username'}\n&quot;;
print MAIL &quot;Url- $form{'userweb'}\n&quot;;
print MAIL &quot;Message- $form{'message'}\n&quot;;
print MAIL &quot;Ip- $ENV{'REMOTE_ADDR'}\n&quot;;
close (MAIL);

# Mail to User
open (MAIL, '|-', &quot;$sendmail -t&quot;) or die $!;
print MAIL &quot;To: $form{'usermail'}\n&quot;;
print MAIL &quot;From: $form{'weburl'}\n&quot;;
print MAIL &quot;Subject: Thank you for signing my form!\n\n&quot;;
print MAIL &quot;$thanks\n&quot;;
print MAIL &quot;You said:\n&quot;;
print MAIL &quot;$form{'message'}\n&quot;;
close (MAIL);

# Let's give them something to look at, might as well, they were nice enough to fill out the form!

####################### BEGIN EDITING HERE 2 ######################################
print <<end_of_results;
<html>
<head>
<title>Results Page</title>
</head>

<table width=&quot;75%&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;2&quot;>
<p>Thank you for filling out the form. If you are awaiting assistance and
you asked a question, please allow upto 24 hours for my to get back to
you.</p>
<p>- $yourname</p>
</td>
</tr>
<tr>
<td colspan=&quot;2&quot;><font color=&quot;#9933CC&quot;>Here is a copy of what you sent...</font></td>
</tr>
<tr>
<td width=&quot;9%&quot;><font color=&quot;#666666&quot;>name:</font></td>
<td width=&quot;91%&quot;><font color=&quot;#999999&quot;>$form{'username'}</font></td>
</tr>
<tr>
<td width=&quot;9%&quot;><font color=&quot;#666666&quot;>email:</font></td>
<td width=&quot;91%&quot;><font color=&quot;#999999&quot;>$form{'usermail'}</font></td>
</tr>
<tr>
<td width=&quot;9%&quot;><font color=&quot;#666666&quot;>url:</font></td>
<td width=&quot;91%&quot;><font color=&quot;#999999&quot;><a href=&quot;$form{'weburl'}&quot;>$form{'weburl'}</a></font></td>
</tr>
<tr>
<td width=&quot;9%&quot;><font color=&quot;#666666&quot;>message:</font></td>
<td width=&quot;91%&quot;><font color=&quot;#999999&quot;>$form{'message'}</font></td>
</tr>
<tr>
<td width=&quot;9%&quot;><font color=&quot;#666666&quot;>Rec. IP:</font></td>
<td width=&quot;91%&quot;><font color=&quot;#999999&quot;>$ENV{'REMOTE_ADDR'}</font></td>
</tr>
<tr>
<td width=&quot;9%&quot;> </td>
<td width=&quot;91%&quot;> </td>
</tr>
</table>

end_of_results
 
My pleasure, this is actually a script-in-making, it's going to be an anonymous emailer...and it's half way done with the script above..

Hope this helped.

sulfericacid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top