#-*-perl-*-
# Perl automated responses for the project filter.  Include with
# "require".
#
# Paul, Oct 23 94
#

sub NotAuthMail {
    #  Tell em so!
    $outmail = "| $sendmail $MainHeader{email}";
    open (TELLEM, $outmail);
    print TELLEM <<NASTYMESSAGEDONE;
Subject: Not an Authorized User

Hello.

Your email address, $MainHeader{'email'}, is not on the
$organization group list of authorized posters to the group
projects mail archive.  Thus, your mail has been rejected.

If you do not think this is correct, please contact the projects
page maintainer, $maintainer.

$outgoingsig

------------ your message -------------
NASTYMESSAGEDONE
    open(ORIG,"<$hthome/$$.txt");
    print TELLEM while (<ORIG>);
    close ORIG;
    close TELLEM;
}

sub bouncedmail {
    #  Tell em so!
    $outmail = "| $sendmail $maintainer";
    open (TELLEM, $outmail);
    print TELLEM <<BOUNCE;
Subject: Bounced Mail

Hi Maintainer.

This is a bounce projects got.  Deal.

$outsig
------------ your message -------------
BOUNCE
    open(ORIG,"<$hthome/$$.txt");
    print TELLEM while (<ORIG>);
    close ORIG;
    close TELLEM;
}


sub HelpMail {
    $email = $MainHeader{'email'};
    $printname = $MainHeader{'name'};
    if ($printname =~ m/^\s*(\S+)\s+(\S+)\s*$/) {
	$printname = $1;
    }
    $outmail = "| $sendmail -F\"Helpful Projects Subroutine\" $email";
    open (TELLEM, $outmail);
    print TELLEM <<HELPMESSAGEDONE;
Subject: Projects Page Help

Hello $printname

You requested help on how to use the projects page.  Here it is.

To mail to projects, you need to send your Email to
$originator.  Somplace in the text of your
body, on a stand alone line, should be the words

project projid

eg,

project 3DBH

Then, your mail will automatically go to the page related to your
project.  The page will also mail to everyone on a list.

If you specify an invalid or no project, your mail will be returned for you 
to try again.  If you try to post to a group for which you have no permissions,
you will also get a fail notice.

Currently recognized project codes and projects which you are allowed to 
post to are:

HELPMESSAGEDONE
    $matches = 0;
    foreach $projid (sort keys(%projects)) {
	$authuser = 0;
	$evstr = "foreach \$USER (\@x$projid) {\$authuser = 1 if (\$USER =~ m/$MainHeader{'matchthis'}/);}";
	eval $evstr;
	print TELLEM "$projid\t\t: $projects{$projid}\n" if ($authuser);
	$matches++ if ($authuser);
    }
    print TELLEM "You are not authorized to post to any project\n"
	if (!$matches);

    print TELLEM <<HELPMESSAGEDONE;

The Projects Page has quite an advanced Mime Compliance.  Any Mime Compliant 
mailer should have no difficulty communicating types image/gif image/jpeg
application/postscript video/mpeg video/qt and various text types.
Eudora users: you need to use the newest version of Eudora
and send your mime attatchments in "Apple Double" with "qp" clicked.

The projects page, $htserverhome, contains
links to each sub-page project. 

All mails, even failed ones and help requests, are recorded in a Log.
This allows us to track usage and unauthorized accesses.

Please contact $maintainer  if you have any questions, comments, 
or improvements.

$outgoingsig

HELPMESSAGEDONE
}

sub InvalidProject {
    # Tell em so, but be a bit more polite
    print "IN INVALIDPROJECT\n";
    $email = $MainHeader{'email'};

    $outmail = "| Mail -s \"Invalid Project Name\" $email";
    print "$outmail\n";
    @printproj = keys %projects;

    open (TELLEM, $outmail);
    print TELLEM <<NOTSONASTYMESSAGEDONE;

Hello.

Your message either did not contain or contained an incorrect
project.  Remember, someplace in the text of your mail, you 
need to include a line which reads

project projectcode

where projectcode is one of the following:

@printproj

Your project came through as

project $theproject

If you specified a correct project and still received this message,
please contact $maintainer.

Thank you.  Your original message is included below.

$outgoingsig

------------ your message -------------
NOTSONASTYMESSAGEDONE
    open(ORIG,"< $hthome/$$.txt");
    print TELLEM while (<ORIG>);
    
    close ORIG;
    close TELLEM;
}


# Exit with status 1
1;
