I'm sending a mutlipart email with a couple of attachments. In a pinch, this is the code:
my $mime = MIME::Lite->new(
From => 'admin@server',
To => 'you@overthere',
Subject => "Your invoice",
Type => 'multipart/mixed',
$mime->attach( Data => 'Heres your invoice' );
$mime->attach( Data => $invoice_as_pdf, Type => 'AUTO', Dispositio
+n => 'attachment', Filename => 'invoice.pdf' );
$mime->send( 'sendmail', FromSender => 'admin@server' );
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:
Content-Type: multipart/mixed; boundary="_----------=_1365192382184080
X-Mailer: MIME::Lite 3.028 (F2.82; T1.34; A2.09; B3.13; Q3.13)
Date: Fri, 5 Apr 2013 14:06:22 -0600
Subject: Your invoice
This is a multi-part message in MIME format.
Heres your invoice
Content-Disposition: attachment; filename="invoice.pdf"
Content-Type: application/octet-stream; name="invoice.pdf"
Of course the MUA displays the Content-* lines and the base64 file.
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.