Hi the code below is supposed to get the email address from the mbox compare it to a database with spam email address.If a match is found then relabel the subject line of the email message with subject:{SPAM}.But this is not the case. The program runs but nothing happens. Can anybody help me please its driving me mad!!
#! usr/bin/perl -w
use DBI;
open (HEADER,"+>/root/mbox" or die "Could not open the file";
my $username = 'me';
my $password = '';
my $dbh = DBI->connect("DBI:mysql:spamdb",$username,$password,);
my $sql = "SELECT subject, address from addsubj";
my $sth = $dbh->prepare($sql) || die "Error preparing DBI:errstr";
my $result = $sth->execute || die "Error executing: $DBI::errstr";
while(my $rowref = $sth->fetchrow_hashref)
{
$row=1;
$row = "$rowref->{address}\n";
$row = "$rowref->{subject}\n";
while(<HEADER>)
{
$subject = $_;
#if((/From[^\@]+)/) eq $rowref->{address})
if((/^From:/) eq $rowref->{address})
{
$subject=~ s/Subject:/Subject:{SPAM!}/;
print "$subject";
}
if( (/^Subject:/) eq $rowref->{subject})
{
$subject=~ s/Subject:/Subject:{SPAM!}/;
print "$subject";
}
}
}
$sth->finish;
$dbh->disconnect;
#! usr/bin/perl -w
use DBI;
open (HEADER,"+>/root/mbox" or die "Could not open the file";
my $username = 'me';
my $password = '';
my $dbh = DBI->connect("DBI:mysql:spamdb",$username,$password,);
my $sql = "SELECT subject, address from addsubj";
my $sth = $dbh->prepare($sql) || die "Error preparing DBI:errstr";
my $result = $sth->execute || die "Error executing: $DBI::errstr";
while(my $rowref = $sth->fetchrow_hashref)
{
$row=1;
$row = "$rowref->{address}\n";
$row = "$rowref->{subject}\n";
while(<HEADER>)
{
$subject = $_;
#if((/From[^\@]+)/) eq $rowref->{address})
if((/^From:/) eq $rowref->{address})
{
$subject=~ s/Subject:/Subject:{SPAM!}/;
print "$subject";
}
if( (/^Subject:/) eq $rowref->{subject})
{
$subject=~ s/Subject:/Subject:{SPAM!}/;
print "$subject";
}
}
}
$sth->finish;
$dbh->disconnect;