1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#!/usr/bin/perl
use lib "lib", "t";
use MIME::Lite;
use Test::More;
use Utils;
if (eval { require MIME::Types; MIME::Types->VERSION(1.28); 1 }) {
plan tests => 1;
} else {
plan skip_all => "MIME::Types >= 1.28 not available";
}
$MIME::Lite::VANILLA = 1;
# warn "#\n#Testing MIME::Types interaction\n";
my $msg = MIME::Lite->new(
From => 'me@myhost.com',
To => 'you@yourhost.com',
Cc => 'some@other.com, some@more.com',
Subject => 'Helloooooo, nurse!',
Data => "How's it goin', eh?"
);
# this test requires output in a particular order, so specify it
$msg->field_order(qw(
Content-Transfer-Encoding
Content-Type
MIME-Version
From
To
Cc
Subject
));
$msg->attach(
Type => 'AUTO',
Path => "./testin/test.html",
ReadNow => 1,
Filename => "test.html",
);
(my $ret=$msg->stringify)=~s/^Date:.*\n//m;
my $expect=<<'EOFEXPECT';
Content-Transfer-Encoding: 7bit
Content-Type: multipart/mixed; boundary="_----------=_0"
MIME-Version: 1.0
From: me@myhost.com
To: you@yourhost.com
Cc: some@other.com, some@more.com
Subject: Helloooooo, nurse!
This is a multi-part message in MIME format.
--_----------=_0
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
How's it goin', eh?
--_----------=_0
Content-Disposition: inline; filename="test.html"
Content-Transfer-Encoding: 8bit
Content-Type: text/html; name="test.html"
This isn't really html. We are only checking the filename silly.
--_----------=_0--
EOFEXPECT
is($ret, $expect, "we got the message we expected");
|