Link to home
Start Free TrialLog in
Avatar of CJ_S
CJ_SFlag for Netherlands

asked on

Form emailing

I ain't no expert in perl at all, but I thought the following should work to get all of the fieldnames and values of a form and be able to put it in the mail......NOT! So, could you guys gimme a hand?

#!/usr/bin/perl

print "Content-type: text/html\n\n";
$orgmail = "postmaster\@hbd.nl";

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

print MAIL "To: cdevos\@doublespace-eu.com\n";
print MAIL "From: $orgmail ($orgmail)\n";
print MAIL "Subject: Reactieformulier\n";


read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
print MAIL "pairs\n\n";
print MAIL $buffer;

foreach $pair (@pairs){
   ($name, $value) = split(/=/, $pair);
   
   print MAIL "$value\n";
   print "$value\n";
}


#print MAIL "- yaddiya";

close (MAIL);      



Avatar of Chris S
Chris S
Flag of India image

1. what is the output of the script ?

2 .ARe you using a GET method of POST method in the html form which calls the script ..it must be POST method ..
Avatar of maneshr
maneshr

the script is syntactically ok.

can you pl. let us know the exact nature of the problem.

what does happen? do you get an error? is there no error but the email is not sent out??

what should happen?

chances are the problem might be with the email server that is supposed to send out the email!!

Let us know.
You have posted this Q twice. pl delete one of them.
Avatar of CJ_S

ASKER

The email is sent alright, but ther'es no item of the form being sent. with this:

print MAIL "$value\n";

inside the foreach I supposed that it should fill the MAIL, but it doesn't. if I put something outside the foreach.it is working.

I'll try the POST method in a minute...thought it should be GET with this.....
i would suggest that you try this.

Add ..

$|++;

at the top of the program..



change ..
  print MAIL "$value\n";


to..
  print MAIL $value,"\n";

let us know how it goes.
ASKER CERTIFIED SOLUTION
Avatar of SEve
SEve

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CJ_S

ASKER

Answer accepted
Avatar of CJ_S

ASKER

OOPS, sorry...totally forgot about this. Hope you don;'t mind......i solved it anyway, with some of your help =).

Thanks