I did something like this a little over a year ago with Net::SMTP doing the deliveries. If I were writing this today, it would probably be a bit different, but here's what I had back then:

# $from is to be the envelope sender # $msg is the full text of the message, headers and all # (everything after the initial 'From ' line in the mbox sub attempt_delivery { my ( $from, $msg ) = @_; my $smtp; my $success; my $sleepy = 1; while ( ! ( $smtp = Net::SMTP->new('smtp.example.com') ) ) { print "Sleeping $sleepy...\n"; sleep( $sleepy ); $sleepy *= 2; $sleepy = 60 if ( $sleepy > 60 ); } if ( ! $smtp->mail( $from ) ) { $smtp->quit(); return 0; } # in my script, $to is a global variable if ( ! $smtp->to( $to ) ) { $smtp->quit(); return 0; } if ( ! $smtp->data() ) { $smtp->quit(); return 0; } if ( ! $smtp->datasend( $msg ) ) { $smtp->quit(); return 0; } if ( ! $smtp->dataend() ) { $smtp->quit(); return 0; } if ( ! $smtp->quit() ) { return 0; } return 1; }

I was parsing through my mbox files by hand, mostly because they were mangled in various unseemly ways. If yours are pristine, you'll probably want to check out Email::Folder::Mbox or Mail::Mbox::MessageParser or something. CPAN has many candidates.


In reply to Re: Resend Email from Mbox format by kyle
in thread Resend Email from Mbox format by gowthamtr

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.