in reply to Preprocessing STDIN

That looks like it should work, unless the email in question was generated by Outlook in which case it will have a non-conformant header. (What? You don't know all of the headers that could possibly be contained in an email message and don't know to break out at the first thing that doesn't fit? Then you are probably a Netscape client and we want to make you crash. So not sorry if you are merely a trusting Perl script...)

So I don't know what the issue is, but I would suggest that the first thing you should do is take XML::Twig out of it. Just try to print the contents of the file after the header and see if that looks reasonable. Print it to a file and see if XML::Twig is happy with that. Then proceed from there.