#!/usr/athena/bin/perl
sub bounceUser {
  my ($address) = @_;
  system("/usr/local/majordomo/bounces/bounce-handler.pl $address");
}

$addr = $ENV{'LOCAL'};
$exit_status = 0;

if ($addr =~ /-recipients-owner-([\w\d\.\-]+)=([\w\d\.\-]+)$/) {
  $bad_address = "$1\@$2";
  &bounceUser($bad_address);
  $exit_status = 99;
}

if ($addr =~ /-recipients-owner-$/) {
  while(<>) {
    chop;
    last if /^--- Below this line is a copy of the message.$/;
    if (/^\<([\w\d\.\-\@]+)\>:$/) {
      &bounceUser($1);
      $exit_status = 99;
    }
  }
}

exit $exit_status;
