Perl CGI Script EMails nothing 
Author Message
 Perl CGI Script EMails nothing

Hi I have been just starting to learn perl and my first script just don't
work.
It debugs ok and it sends the mail ok. Unfortunately it does not send the
main message and i cannot find a syntax error in the script.
I know it's bad practice to just post a load of code to a ng however if
anyone can see a bug screaming out then please mail me.
I checked the content length and the script definately receives some text
but then loses it somewhere

Thanks in advance
Alex

#! /bin/perl

#This is the sub main part of the script
%data_in = &Parse_String();
 foreach $key (sort keys(%data_in))
 {
 $mail .="$key:\n";
  foreach (split (" : ",$data_in{$key}))
  {
  $mail .= "$_\n\n";
  }
 }
&Email_Str ($mail);
&ResponsePage;

sub Parse_String
{

 #Check how the data was sent : POST or GET
 if  ($ENV{'REQUEST_METHOD'} eq "POST")
   {
  read(STDIN,$Parse_String,$ENV{'CONTENT_LENGTH'});
  }
 else
  {
  $Parse_String=$ENV{'QUERY_STRING'};
  }
 #NOW TAKE THE STRING AND CONVERT + TO SPC
 $Parse_String=~ s/\+/ /g;
 #CREATE ASSOCIATIVE ARRAY AND ADD VALUES


 {
   ($name,$value)=split(/=/,$Pair_Values);
   $name= ~s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C",hex($1))/ge;
   $value= ~s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C",hex($1))/ge;
 #IF MULTIPLE VALUES WITH SAME NAME THEN DEAL WITH IT
   if (defined($Parse_String{$name}))
    {
    $Parse_String{$name} .= " : " .  $value;
    }
   else
    {
    $Parse_String {$name}=$value;
    }
 }
return %Parse_String;

Quote:
}

#Write Confirmation Page
#Temporary Response Page
sub ResponsePage {
 local (%ResponsePage);
 print "Content-type: text/html\n\n";
 print "<html><Title>Form Posted</Title>";
 print "<Body><p><p><p><p><H1>Thankyou For Filling this Form in</H1>";
Version</a>";
 print "</Body> </html>";
return %ResponsePage;

Quote:
}

#send Email

sub Email_Str
{

 open (MAIL, "|/usr/lib/sendmail -t") ||
 die "Context-type: text/text\n\nCan't open /usr/lib/sendmail !\n";


 print MAIL "Subject: Mail FeedBack\n";
 print MAIL "$message \n\n";
 return close(MAIL)

Quote:
}

--
The Wizzard


Sat, 28 Jul 2001 03:00:00 GMT  
 Perl CGI Script EMails nothing
Re: Perl CGI Script EMails nothing, "AE <- )"

"AE> #! /bin/perl

perl -w

use strict;

"AE> #This is the sub main part of the script
"AE> %data_in = &Parse_String(); foreach $key (sort
"AE> keys(%data_in)) { $mail .="$key:\n"; foreach
"AE> (split (" : ",$data_in{$key})) { $mail .=
"AE> "$_\n\n"; } } &Email_Str ($mail);
"AE> &ResponsePage;

[snip weird manual extraction of parameters]

I'd use the CGI.pm module if I were you, life will
become much easier.


"AE> Mail FeedBack\n"; print MAIL "$message \n\n";

There should be a blank line at the end of the
headers.  Using MIME::Tools and Mail::Send would
simplify life for this part.

hth
tony
--
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:



Sat, 28 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. nothing =~ nothing??

2. Perl/CGI script to validate email addresses

3. Need a email perl/cgi script

4. cgi-perl email script?

5. how can I make my perl cgi script email to a newsgroup

6. Need CGI script to get email after user fills web form

7. cgi script to send to URL and via email

8. Attaching a file to an email with a cgi script

9. CGI script results to email?

10. CGI script for formatting Email

11. Send email with attatchment using CGI script?

12. Need CGI script to get email after user fills web form

 

 
Powered by phpBB® Forum Software