Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

CGI Scripts

  • 08-03-2005 03:01AM
    #1
    Closed Accounts Posts: 290 ✭✭


    Apologies if this has been asked before (but the site search is offline at the mo) but does anyone know a a site providing fa ree CGI script for emailing me the contents of a simple web form?


Comments

  • Closed Accounts Posts: 7,488 ✭✭✭SantaHoe


    Yeah, google for Matt's FormMail.pl
    You'll need to know the location of the servers sendmail script to set it up, but the peeps you host with should be able to tell you this if it's not already in their FAQ.
    I think v1.92 is the most recent version of FormMail.pl so make sure you don't get anything older, as the older versions are apparently vulnerable to spammers using it to send unsolicited email through your site.
    It takes a bit of reading, but there's not that much to set up... only in the first few lines, and it's explained pretty well in the comments.
    The only annoying thing is the unix line breaks, so if you're editing it in windows be sure not to disturb them and try to work with the jumbled version :eek:
    I find it stops working if you disturb the line breaks, so notepad.exe with wordwrap off should do the trick.


  • Closed Accounts Posts: 154 ✭✭smorton


    #!/usr/local/bin/perl
    print "Content-type: text/html\n\n";
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $name =~ tr/+/ /;
    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
    if($name eq "to"){$to="YOUR EMAIL ADDRESS"}
    if($name eq "from"){$from=$value}
    if($name eq "subject"){$subject=$value}
    if($name eq "body"){$body=$value}
    }
    open (MAIL,"|/usr/lib/sendmail -t");
    print MAIL "To: $to\n";
    print MAIL "From: $from\n";
    print MAIL "Subject: $subject\n\n";
    print MAIL "$body\n";
    close MAIL;


    that program is for emailing to ppl in general but it can be easily be modified by changing the lines:
    if($name eq "from"){$from=$value}
    to whatever you want. in the one above there were four text boxes in the form, called to, from subject and body. the line "open (MAIL,"|/usr/lib/sendmail -t");" is different depending on your host. thats the path for netfirms and i thik most hosts. also the from address can be put as whatever you want. good for some fun :)


Advertisement