package Mail::SpamAssassin::Plugin::ExtraTokens;
my $VERSION = 0.01;

use strict;
use Mail::SpamAssassin::Plugin;

use vars qw(@ISA);
@ISA = qw(Mail::SpamAssassin::Plugin);

sub dbg { Mail::SpamAssassin::Plugin::dbg ("ExtraTokens: @_"); }

sub new
{
    my ($class, $mailsa) = @_;

    $class = ref($class) || $class;
    my $self = $class->SUPER::new($mailsa);
    bless ($self, $class);

    return $self;
}

sub extract_metadata
{
    my ($self, $opts) = @_;

    my $msg = $opts->{msg};

    my $cnt = 0;
    my $data;
    foreach my $p ($msg->find_parts(qr/^/i,1,1)) {
        my $type = $p->{'type'} || '';
        my $name = $p->{'name'} || '';
        next unless $name =~ /\S/;
        $name =~ s/\.([^.]+)$/ E*$1/;
        $data .= "$type $name ";
    }

    $msg->put_metadata("X-Filenames", $data) if defined $data;
}

1;
