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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.