# fakenames plugin for SpamAssassin: checks for obviously made-up names
# Adam Sampson <ats@offog.org>

package FakeNames;
use strict;
use Mail::SpamAssassin;
use Mail::SpamAssassin::Plugin;
our @ISA = qw(Mail::SpamAssassin::Plugin);

sub new {
	my ($class, $mailsa) = @_;
	$class = ref($class) || $class;
	my $self = $class->SUPER::new($mailsa);
	bless ($self, $class);
	$self->register_eval_rule("name_in_subject");
	return $self;
}

# Look for first name in subject line ("hi it's Lea")
sub name_in_subject {
	my ($self, $permsgstatus) = @_;

	my $name = $permsgstatus->get('From:name');
	my $subject = $permsgstatus->get('Subject');

	$name =~ s/^\s*(\S+).*$/$1/;
	if ($name ne '' and index($subject, $name) != -1) {
		return 1;
	}

	return 0;
}

1;

