Reading an email from an mbox file and resending to a different address without modification


I'm trying to emulate the "Redirect" function of some email clients
but am not having much success. I am sending messages with
ActionMailer templates just fine so I'm pretty sure my environment is
set up correctly and that my mail server is accepting the messages to

I am reading messages out of an mbox file and parsing them into RMail
objects with Then I'm storing some info about
the message as well as storing the a text version of the RMail object
in a field as the "raw" message (I get the text version of RMail using
to_s() )

At a different point in the program, I want to "resend" or "redirect"
the message to an external email address - but I want it to appear in
their mailbox unmodified from the original.

I thought the easiest way to do this would be to use Net::SMTP.start()
and pass it the "raw" message as well the from/to address for the SMTP
transaction (which shouldn't affect the RFC822 headers in the original
message being delivered). I realized along the way that I need to
delete the first line from the mbox file that contains the From and

When I try this with simple text emails it seems to work. But when I
try to attach MIME emails it seems to get confused and creates a new
set of RFC822 headers and puts the entire MIME message (including its
RFC822 headers) into the body of the new message that is sent.

      smtp.send_message raw_mail, "", ""

Any pointers? Is there an easier way to resend a raw RFC822 message
than Net::SMTP.start() ? Any idea what could be wrong with my message