Here is what a redirected catchall email sent to anyone@mysite.com looks like with a quick hack to grab the last for (original) target (2) and the To: field (3) - the (n) are added for clarity. There are some mail Parsers on CPAN that you should look at but as you will have to do the guestimations by hand this may just do. You could use something like String::Approx to automatically guess the best address.
my $message = join'',<DATA>; my ( $for, $to ) = $message =~ m/.*for\s+<([^>]+)>.*\nTo:\s+([^\n]+)/s +; print $for, $/, $to; __DATA__ Return-Path: <jfreeman@tassie.net.au> Received: from zeus.tassie.net.au (zeus.tassie.net.au [203.57.213.21]) by perseus.tassie.net.au (8.12.2/8.12.2/RG2.2) with ESMTP id g +3IB9LuQ085226 for <jfreeman@tassie.net.au>; Thu, 18 Apr 2002 21:09:21 +1000 +(EST) Received: from perseus.tassie.net.au (perseus.tassie.net.au [203.57.21 +3.25]) by zeus.tassie.net.au (8.8.8/8.8.8) with ESMTP id VAA16087 for <anyone@mysite.com(1)>; Thu, 18 Apr 2002 21:10:26 +1000 (E +ST) Received: from tassie.net.au (dialin67.hbt.tassie.net.au [203.57.210.6 +7]) by perseus.tassie.net.au (8.12.2/8.12.2/RG2.2) with ESMTP id g +3IB9KuQ085223 for <anyone@mysite.com(2)>; Thu, 18 Apr 2002 21:09:20 +1000 (E +ST) Message-ID: <3CBEAB8D.A7CD69BC@tassie.net.au> Date: Thu, 18 Apr 2002 21:18:37 +1000 From: James freeman <jfreeman@tassie.net.au> Organization: Adajio X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en,pdf MIME-Version: 1.0 To: anyone@mysite.com (3) Subject: redirect Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mozilla-Status: 8001 X-Mozilla-Status2: 00000000 X-UIDL: lL`"!A@*!!#/'#!RO3"! This message will get redirected to catchall because anyone is not a valid account at mysite.com
cheers
tachyon
In reply to Re: Routing mail collected from a POP3 Server
by tachyon
in thread Routing mail collected from a POP3 Server
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |