Re-Queing a mailbox full of bounced messages
We've recently run in to a situation where we had a fairly large number of legitimate messages bounce due to a misconfigured MTA. Once we fixed the MTA, we needed to get all of those messages back out the door again. It was a job for CPAN.
use strict;
use warnings;
use Mail::Box::Manager;
use Email::MIME;
use Email::Send;
foreach my $mbox (@ARGV) {
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(folder => $mbox);
my $sender = Email::Send->new({mailer => 'SMTP'});
$sender->mailer_args([Host => 'localhost']);
foreach my $msg ($folder->messages) {
PART: foreach my $part ($msg->parts('ALL')) {
my $body = $part->decoded;
if ($body =~ /This is the mail system at/) {
next PART;
} elsif ($part->decoded =~ /Action: failed/) {
next PART;
} else {
my $email = Email::MIME->new(\$part->decoded);
print "Sending to: " . $email->header("To") . "\n";
$sender->send($email);
}
}
}
}
The code uses a couple of different modules:
- Mail::Box::Manager: handles opening a mailbox (in pretty much every common format) and extracting messages.
- Email::MIME: lets you construct a new email from a MIME encoded message.
- Email::Send: takes our Email::MIME object and sends it out (in this case, via SMTP, but you can choose your mechanism.)
Avvo Launches 1
Avvo just unveiled their new platform for helping consumers find lawyers. We helped design and implement their production systems infrastructure, and we're pretty proud of how it turned out.
Some of the press they received this morning include the The Seattle Times, John Cook's Venture Blog, The Seattle Post Intelligencer and CNET. (Here is a Google news search for Avvo; more are appearing all the time.)
Avvo's got a great team, a cool product, and we couldn't be happier for them. Congratulations!