If you just run it, it works. But when it's called from our app running in mod_perl, it gets an extra \n after the boundary, which means MUA won't parse the headers, you don't really get an option to download the file, it's a wreck, looks like this:

So far I found that MIME::Lite opens a pipe to sendmail, prints the boundary to the handle and then passes the handle to a function which prints the part to it. As a matter of fact, I opened MIME::Lite.pm and used the $part->to_string method to print it along with the boundary in a single call and it worked just fine.

My best guess is that someone/something is messing with the stream, but I have no clue. Anyone ever observed a problem like this one before? Any clues? Any MIME::Lite alternatives which would work with my sample code? I need it to use sendmail and be able to force the From field because I'm using Amazon's relay servers.