Reply
Old 04-01-2004, 10:02 PM cgi email
dbzguy's Avatar
Ultra Talker

Posts: 345
Location: Artic
this is annoying!
I tryng to get an email form to work using cgi/perl but i dont know anything about perl so if any body could help my :

#!/usr/bin/perl

# The following accepts the data from the form

if ($ENV{'REQUEST_METHOD'} eq 'POST') {

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM{$name} = $value;
}



# The following sends the email

open (MESSAGE,"| /usr/sbin/sendmail -t");

print MESSAGE "To: $FORM{to}\n";

print MESSAGE "From: $FORM{name}/n";
print MESSAGE "Reply-To: $FORM{email)/n";

print MESSAGE "Subject: website email\n\n";
print MESSAGE "Wrote:\n\n";
print MESSAGE "$FORM{body}\n";
close (MESSAGE);

&thank_you;
}




#The following creates the Thank You page display

sub thank_you {

print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Thank You!</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=#000000 TEXT=#00ced1>\n";
print "<H1>Thank You!</H1>\n";
print "\n";
print "<P>\n";
print "<H3>I will reply within a week..<BR>\n";
print "<h4>Hope you like my site.</h4>\n";
print "<P>\n";
print "</BODY>\n";
print "</HTML>\n";
exit(0);
}
__________________
W3 Dynamic Webhosting-Great Hosting, great service, GREAT PRICES!

PHP Code:
<?PHP if(ping == true) { attackuserip(); } ?>
dbzguy is offline
Reply With Quote
View Public Profile Visit dbzguy's homepage!
 
When You Register, These Ads Go Away!
Old 04-03-2004, 06:57 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
What's the problem you're having? Simply upload your script and CHMOD it to 755. Then create a form with the fields to, name, email and body and point it to the script.

Just a note, I would change:
Code:
 print MESSAGE "To: $FORM{to}\n";
to
Code:
 print MESSAGE "To: your\@emailaddress.com\n";
Allowing the 'to' address to be set in the form is very insecure and it is extremely easy for spammers to use your form to send out spam.
__________________
Free Webmaster Help - Everything a webmaster needs - for free
Free-Webhosting.info - Free web hosts reviewed and rated
Web Hosting Hunt - Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile Visit david's homepage!
 
Reply     « Reply to cgi email
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11819 seconds with 12 queries