#!/usr/athena/bin/perl

use strict;
use warnings;
my $box = 'inbox-nospam';
my $mail = '';

while ($_ = <STDIN>) {
  $mail .= $_;
  if (/^$/) {
    last;
  }
  if (/^X\-Spam\-Flag/) {
    $box = 'inbox-spam';
  }
}
while ($_ = <STDIN>) {
  $mail .= $_;
}

open(FILE,"|/usr/local/bin/file-message -f $box") || die "Can't open file-message : $!";
print FILE $mail;
close FILE;

