#!/usr/local/bin/perl # CGI script to accept a form post and do three things: # - Send all data that was entered to a particular email address # - Request a subscription to mvvplist from majordomo-mvvp # - Display a thank you window # Where to send the data entered by the user $collector = "lsiegel\@cpeo.org"; #$collector = "robw\@worldspot.com"; # Formal sender of email and subscription request $formalRequestor = "robw\@worldspot.com"; # Majordomo to send subscription to $majordomo = "majordomo-mvvp\@mvvp.org"; # List to subscribe to $listName = "mvvplist"; # Will hold the new subscriber's email address $sender = ""; &parsedata; &sendemail; &sendsubscription; &printthanks; sub parsedata { # For debugging open(F, ">/tmp/sub-mvvplist.log"); read(STDIN, $in, $ENV{'CONTENT_LENGTH'}); @in = split(/&/, $in); print F "Parsing the $#in header fields\n"; foreach $i (0 .. $#in) { $in[$i] =~ s/\+/ /g; $in[$i] =~ s/%(..)/pack("c",hex($1))/ge; ($key, $val) = split(/=/,$in[$i],2); $in{$key} .= '\0' if (defined($in{$key})); $in{$key} .= $val; print F "$key: $val\n"; if ( $key == "email" ) { $sender = $val; print F "found email field\n"; } } print F "majordomo: $majordomo\n"; close F; } sub sendsubscription { open (SENDMAIL, "| /usr/sbin/sendmail -t -n"); print SENDMAIL "From: $formalRequestor\n"; print SENDMAIL "To: $majordomo\n"; print SENDMAIL "Subject: subscribe $listName $sender\n\n"; print SENDMAIL "subscribe mvvplist $sender\n"; close SENDMAIL; } sub sendemail { open (SENDMAIL, "| /usr/sbin/sendmail -t -n"); print SENDMAIL "From: $formalRequestor\n"; print SENDMAIL "To: $collector\n"; print SENDMAIL "Subject: New subscriber\n\n"; foreach $i (0 .. $#in) { ($key, $val) = split(/=/,$in[$i],2); print SENDMAIL "$key: $val\n"; } close SENDMAIL; } sub printthanks { print "Content-type: text/html \n\n"; print <<"EOM";