Can't 'Override' send address in send
"Edward D. Bryson" <[email protected]> Thu, 29 Apr 2004 12:07:48 -0400
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <001801c42e04$1e002790$500aa8c0@edbhp> |
Greetings:
I've been beating my head against the wall. Please help.
We're using Mail::Box for folder management etc. We move mail from folder to
folder etc all ok.
Trying to get a simple script to scan through an archived mailbox and send
each mail back through the system but to a DIFFERENT destination. i.e. a
mass forward of already received mail back through our sendmail / spam
assassin / procmail setup.
My problem: According to my reading of documentation you should be able to
'override' the destinations by adding: to => string to the send().
Here's the script - it opens the folder, scans through, dumps 3 line of text
and sends the message. No matter what I try, it (re)sends the email to the
original destination NOT to my override:
#!/usr/bin/perl
####################################################
#
# mailabox.pl - mail a mail box
#
# ./mailabox.pl folder email
#
####################################################
use strict;
use Mail::Box::Mbox;
my $enum = 0;
my $date = '';
my $from = '';
my $subject = '';
my $folderspec = $ARGV[0];
my $folder = Mail::Box::Mbox->new(folder => $folderspec);
if (!defined($folder)) {
print "Errors: Can't Open Folder\n";
}
else {
foreach my $message ($folder->messages) {
$enum++;
my $sender = $message->sender;
$from = '';
$from = $sender->format() if (defined($sender));
$subject = $message->subject;
$from = '' if (!defined($from));
$subject = '' if (!defined($subject));
my $enumtxt = $enum;
$enumtxt = '0' . $enumtxt if ($enum < 10);
$enumtxt = '0' . $enumtxt if ($enum < 100);
$enumtxt = '0' . $enumtxt if ($enum < 1000);
$enumtxt = '0' . $enumtxt if ($enum < 10000);
print $enumtxt, "\n ", $from, "\n ", $subject, "\n";
print " Sent!!\n\n" if ($message->send(to => $ARGV[1]));
}
$folder->close;
}
Tested hundreds of times as: ./mailabox.pl test.aaa [email protected]
Anyones quick help to my stupidity would be appreciated. A customer got
setup as the return address for 100M of spam and we're trying to resort his
mailbox for him.
-Ed
Edward D. Bryson
Esper Systems
Knoxville TN USA