Click to See Complete Forum and Search --> : No email from forms


tsugi
08-17-2006, 06:27 PM
Hi y'all,

Apologies for what will no doubt be a stupid question.

I'm testing a form:

<HTML>
<BODY>
<FORM METHOD="POST" ACTION="/cgi-bin/testing2.cgi">
<PRE>
<input type="hidden" name="submitaddress" value="nobody@nobody.com">
First Name <INPUT TYPE="text" NAME="fname" MAXLENGTH=15 SIZE=15>
Last Name <INPUT TYPE="text" NAME="lname" MAXLENGTH=20 SIZE=20>
E-Mail Addr <INPUT TYPE="text" NAME="email" MAXLENGTH=35 SIZE=35>
<INPUT TYPE="submit" VALUE="Send Mail!">
<INPUT TYPE="reset" value=" Clear-Form">

</PRE>
</FORM>
</BODY>
</HTML>

Which works (no great shakes for you - but a triumph for me!) However I don't get email.

my script:
#!/usr/bin/perl

open (MESSAGE,"| /bin/easymail -t");

print MESSAGE "To: $FORM{submitaddress}\n";
print MESSAGE "From: $FORM{fname + lname}\n";
print MESSAGE "Reply-To: $FORM{email}\n";

print MESSAGE "Subject: Feedback from $FORM{name} at $ENV{'REMOTE_HOST'}\n\n";
print MESSAGE "The user wrote:\n\n";
print MESSAGE "$FORM{feedback}\n";
close (MESSAGE);


print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY BGCOLOR=#FFFFFF>\n";
print "<CENTER>\n";
print "THANK YOU<BR>\n";
print "I will write<BR>\n";
print "you at<BR>\n";
print "</CENTER>\n";
print "</BODY></HTML>";

The 'open (MESSAGE,"| /bin/easymail -t");' bit is for this reason: my hosts say their mail has to go to /bin/easymail. I don't know if anything else has to go round it, I don't actually know what the 'l ' and the '-t' are for. I copied a script (I was allowed) and changed the /usr/bin/sendmail bit to the easymail bit. All to no avail.

Can anyone help? I'm not too sure what on earth the script is saying!

Thanks,

tsugi

tsugi
08-19-2006, 03:53 AM
Just bumping this in the hope it will get someone's attention.
:)

Watts
08-24-2006, 04:12 PM
You need to "get" the information from the form and put it into your variables. Right now you have a form that calls the perl script (to send the email), but you're missing an intermediate step which is to take the information from the form and place it into the email.

Add something like this to the top of your script (just under the shebang #!/usr/bin/perl).

read(STDIN, $strIN, $ENV{"CONTENT_LENGTH"});
@pairs = split(/&/, $strIN);
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}

then you can print $FORM{'whatever your field name is goes here'};

example $FORM{'name'} $FORM{'address'}, etc.

tsugi
08-24-2006, 05:09 PM
Thanks so much for that.

It has helped.

Cheers,

tsugi