Home: Perl Programming Help: Intermediate:
MIME::Lite | 'inline' attachment issue

New User

Oct 18, 2012, 1:07 PM

Views: 3579
MIME::Lite | 'inline' attachment issue

Greetings -- guessing this is an 'intermediate question'. Apologies if it is deemed otherwise.

I'm trying to figure out how to solve several annoying problems with handling inline attachments - specifically, how to resolve (if possible) problems in 'what people see' in the email depending on what flavour/vintage of email client they use.
Consider the following MIME::Lite perl script:

use lib "/usr/local/lib";
use MIME::Lite;

$msg = MIME::Lite->new(
From => 'fred@bedrock.com',
To => 'barney@bedrock.com',
Subject => "test transmission",
Type =>'text/plain',
ReadNow => 1,
Datestamp => 0,
Disposition => 'inline',
Path => "/path/to/file/test.txt"

# $msg->scrub(['content-disposition']);

As you can see, I'm trying to build an email where the body of the note (i.e., the text of the message) is pulled in from an external file (test.txt).

This works perfectly, except that

1\ in Thunderbird 14.xx or newer, not only do I get the contents of test.txt inline in the note (what I want), but I also get test.txt included as an attachment file (in other words, Thunderbird is treating the contents as 'both' inline and attachment at the same time).

2\ in Outlook pre-2010, the recipient gets test.txt as an attachment, but the body of the email is blank. In Outlook 2010, I get the contents of text.txt inline, but no test.txt as an attachment.

3\ in GMail, the contents of test.txt are inline, and there is the 'icon' for an attachment, but test.txt is not attached.

Is there anything obvious that I could try to resolve this inconsistency? At minimum, I want everyone receiving the note to be able to see the contents of test.txt inline. I've tried scrubbing the msg (as shown above), but turning that on/off doesn't seem to change anything.

I'm also open to suggestions o alternative approaches that may not involve MIME::Lite.

Thanks in advance.