I have a special mbox file where each message in the mbox is has one or more attached messages. These were created from being forwarded as an attachment. I have a perl script that uses MIME::Tools and MIME::Parser to parse that mbox file. It can pipe these files to another program (spamassassin), or save them as individual text files which is what I'm doing. I believe these individual files are RFC822 format (not positive). Each text file does not start with "From: ..." so I can't simply cat them back together.
I need a way to reassemble these extracted files back into mbox (mbxcl2) format. Is there a tool or script I can use to reassemble these extracted files?
I tried having my script output them into a single file as they parsed, with a From me\@myserver.com Fri Sep 1 15:18:53 2017\n
. This is enough for mailx viewing on the server, but Dovecot complains: dovecot: imap(me): Error: Syncing INBOX failed: Mailbox isn't a valid mbox file
So I apparently need to do more than just add the "From " separator.