James Arlen writes:
 > We recently came to the aid of a domain that lost its primary and
 > secondary server and the entire list of email recipients.  We accepted
 > delivery of messages into a ./Mailbox.  For the past week we have been
 > collecting up usernames and placing them in .qmail-* files with forwarding
 > information. All mail for which we had (have) no destination is being
 > stored in a single Mailbox (about 100 megs now) through the use of a
 > .qmail-default
 > 
 > Is there a simple way to reprocess our mailbox and get some more of these
 > messages delivered?

Probably something like this, although I don't guarantee the code I
give away for free (that SHOULD be taken as a hint):

#!/usr/bin/perl
# Remember to rename your Mailbox before piping it to this script,
# otherwise you'll set up a race between perl and qmail if there are
# any addresses which are still undeliverable.  I'd bet on qmail.

while(<>) {
  if (/^From /) {
    $inheaders = 1;
    $headers = "";
    next;
  }
  if ($inheaders && /^$/) {
    $sender = s/^Return-Path <(.*)>\n//m;
    $recip = s/^Delivered-To: (.*)\n//m;
    open(O, "|/var/qmail/bin/qmail-inject -f$sender $recip");
    print O $headers;
    $inheaders = 0;
  }
  if ($inheaders) {
    $headers .= $_;
  } else {
    print O;
  }
}

-- 
-russ nelson <[EMAIL PROTECTED]>  http://crynwr.com/~nelson
Crynwr supports Open Source(tm) Software| PGPok | Good parenting creates
521 Pleasant Valley Rd. | +1 315 268 1925 voice | an adult, not a perfect
Potsdam, NY 13676-3213  | +1 315 268 9201 FAX   | child.

Reply via email to