#!/usr/bin/perl # # Perl program to send mail. # # $FreeBSD: www/en/cgi/reg.cgi,v 1.7 2000/04/03 08:45:51 phantom Exp $ sub do_header; sub close_body; $mailprog = '/usr/sbin/sendmail'; print "Content-type: text/html\n\n"; if ($ENV{'REQUEST_METHOD'} eq "get") { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @nvpairs = split(/&/, $buffer); foreach $pair (@nvpairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } if ($FORM{"emaila"} eq "") { print "\n"; print "
\n"; print "Your email address was left blank. Please enter it.\n"; print "\n"; print "\n"; exit(0); } $recipient = $FORM{'recipient'}; exit(0) if $recipient !~ /^[a-z_\.\-]+\@freebsd\.org$/io; $sub_recipient = "majordomo\@FreeBSD.org"; # # format the mail file format MAIL = ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $value . my ($sub_announce, $sub_security, $unsub_announce, $unsub_security) = (); $sub_announce = 1 if $FORM{"announce"} eq "yes"; $unsub_announce = 1 if $FORM{"announce"} eq "no"; $sub_security = 1 if $FORM{"security-notifications"} eq "yes"; $unsub_security = 1 if $FORM{"security-notifications"} eq "no"; # Open the mail file and write to it # if user is subscribing to maillist # which they should be, otherwise why did they hit submit ? if ( $sub_announce || $sub_security || $unsub_announce || $unsub_security ) { open (MAIL, "|$mailprog $sub_recipient") || die "$mailprog not available.\n"; print MAIL "From: $FORM{'emaila'}\n"; print MAIL "Subject: \n\n"; $sub_announce and print MAIL "subscribe freebsd-announce $FORM{'emaila'}\n"; $unsub_announce and print MAIL "unsubscribe freebsd-announce $FORM{'emaila'}\n"; $sub_security and print MAIL "subscribe freebsd-security-notifications $FORM{'emaila'}\n"; $unsub_security and print MAIL "unsubscribe freebsd-security-notifications $FORM{'emaila'}\n"; close (MAIL); } else { &do_header("No action"); print "
No action chosen, hence no action taken.
"; &close_body; exit; } &do_header("Subscription processed"); print "Thank you, $FORM{'emaila'}, for your submission.\n";
print "
The request will need to be authenticated; check your mailbox ";
print "for instructions on how to do this.\n";
&close_body;
sub do_header {
my $title = @_;
print "\n";
print "