Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: PERL Mail Script

  1. #1
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default PERL Mail Script

    Ok, so I keep getting an error when I try to run this cgi.
    "Error message:
    Premature end of script headers: mail.cgi"

    The script:
    Code:
    #!C:\perl\bin\perl.exe
    
    print "Content-type:text/html\n\n";
    
    
    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;
    }
    
    
    $mailprog = 'sendmail\sendmail.exe';
    
    
    $recipient = 'josh_redefined@yahoo.com';
    
    
    open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n");
    
    
    print MAIL "To: $recipient\n";
    
    
    print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
    
    
    print MAIL "Subject: Form Data\n\n";
    
    
    foreach $key (keys(%FORM)) {
    	print MAIL "$key = $FORM{$key}\n";
    }
    
    
    close(MAIL);
    
    
    print <<EndHTML;
    <h2>Thank You!</h2>
    We appreciate your input, we\'ll get back to you as promptly as possible.<br />
    Now, <a href="index.html">GO HOME!</a>
    
    
    sub dienice {
    	my($errmsg) = @_;
    	print "<h2>Oh SNAP!</h2>\n";
    	print "$errmsg<p>\n";
    	print "</body></html>\n";
    	exit;
    }

    The HTML:
    Code:
    <HTML>
     <HEAD>
      <TITLE> CGI Mail Test </TITLE>
     </HEAD>
    
     <BODY>
      <form action="mail.cgi" method="POST">
      Your Name: <input type="text" name="name">
      Email Address: <input type="text" name="email">
      Age: <input type="text" name="age">
      Favorite Color: <input type="text" name="favorite_color">
      <input type="submit" value="Send">
      <input type="reset" value="Clear Form">
      </form>
     </BODY>
    </HTML>
    Any thoughts or ideas?
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  2. #2
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    *bump*

    Any ideas?
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  3. #3
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    does nobody know PERL around here? LOL
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  4. #4
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    I would say probably not, at least no where near the people who know php...

    Any reason why you cant use php?

  5. #5
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Red face

    Honestly, I guess because I tried sitting down and "learning" PHP, but couldn't quite get the hang of it. I got through arrays just fine, and then functions, and variables, but I guess I'm a little too STOOOPID to figure out how to correctly use arguments and such.

    So, I started messing around with PERL and for some reason it just "clicked" much easier in my head than PHP did. So I decided I'd use it instead.
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  6. #6
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    ahhh ok.. Yea the exact opposite for me.. There a good chance that someone around here knows perl... but im not the one..

  7. #7
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    LOL, well thanks anyhoo. Yea, "teaching" yourself everything about the different languages I would say is definitely the "hard" way to learn. I'm getting better, but MAN it's a taking a loooong time.
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  8. #8
    Join Date
    Mar 2006
    Posts
    600
    Thanks
    5
    Thanked 4 Times in 4 Posts

    Default

    It took me pretty good while to get where I am now...

    It took me forever to understand a freakinnn function. lol

    But I finally got the hang of it.. after that it was arrays... For a long time I never understood them.. But I think im inlove with them now...

    HAHA

  9. #9
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    oh......





    --------------
    download

  10. #10
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    oooooooohhhhhhhhhhhhhhhh..........
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •