#!/usr/local/bin/perl

# set our path explicitly
$ENV{'PATH'} = "/bin:/usr/bin:/usr/ucb";

# What shall we use for temporary files?
$tmp = "/tmp/majordomo.$$";

# Read and execute the .cf file
$cf = $ENV{"MAJORDOMO_CF"} || "/etc/majordomo.cf";
if ($ARGV[0] eq "-C") {
    $cf = $ARGV[1];
    shift(@ARGV); 
    shift(@ARGV); 
}
die("$cf not readable; stopped") unless -r $cf;
die("require of majordomo.cf failed") unless require $cf;

# 1.94 has this set in $CF already
$sendmail_command = "/usr/lib/sendmail" unless $sendmail_command;

chdir($homedir) || die("Can't chdir(\"$homedir\"): $!");
unshift(@INC, $homedir);
require "majordomo.pl";

&ParseMailHeader(STDIN, *hdrs);
$reply_to = &RetMailAddr(*hdrs);
$reply_to = join(", ", &ParseAddrs($reply_to));
$in_reply_to = $hdrs{"message-id"} . ", from " . $hdrs{"from"};
$list = $ARGV[0];

# Who should we *really* send to?
$human = "listmanager@$whereami";

# Make sure we aren't looping...
$reply_to = $human if ($reply_to =~ /$whoami/i);
$reply_to = $human if ($from =~ /$whoami_owner/i);

open(MAIL, "|-") || 
    &do_exec_sendmail(split(' ',
	   "$sendmail_command -f$whoami_owner -t"));

print MAIL <<"EOM";
To: $reply_to
From: Majordomo Owner <$whoami_owner>
Subject: Your mail to $whoami_owner
In-Reply-To: $in_reply_to
Reply-To: $whoami_owner

--

This pre-recorded message is being sent in response to your 
recent email to $whoami_owner.

This canned message was necessitated because Majordomo mail 
was often sent erroneously to the (human) Majordomo service 
owner rather than to the automated Majordomo service --
usually due to ill-behaved mailers or gateways.

If you truly wish to contact a human, please direct your
query to $human. 

Otherwise, note your headers and be sure you are directing
all Majordomo mail to $whoami.

Note: If you are having problems using the Majordomo mail
interface, we humbly suggest that you use the Web interface
available at http://sunweb.sandiegoca.ncr.com/cgi-bin/majordomo.

Here's your original, unsent message:

EOM

foreach ("From", "To", "Cc", "Subject", "Date", "Message-ID") {
    $tag = $_;
    tr/A-Z/a-z/;
    if (defined($hdrs{$_})) {
	print MAIL $tag, ": ", $hdrs{$_}, "\n";
    }
}

print MAIL "\n";

while (<STDIN>) {
    print MAIL $_;
}

close(MAIL);
exit 0;



syntax highlighted by Code2HTML, v. 0.9.1