MIME::Lite Problem
Phil White
Usenet at junk.manx.biz
Sat Jan 17 06:08:56 GMT 2009
Hello.
This is an appalling plea for a little help. My sincere apologies, but
I have been bashing my head against this for a week now, and my
ignorance is driving me crazy...
I am trying to amend an existing program that uses MIME::Lite (because
it is both efficient, and is well written).
The email to be sent is first created in full, then, once complete, is
passed to a small subroutine for sending. To this end, the email
message if stored in an anonymous hash.
A summary of the code is given below. What I need to be able to do, is
create a new multipart container, and attach this to the aforementioned
anonymous hash - it is this part that I am failing on...
If you have any ideas on how I might solve my conundrum, I'd be very
grateful.
Best wishes,
Phil.
---
my $msg = {
To => $recipients,
From => $from,
Subject => $subject,
};
$msg->{attach} = [];
push @{ $msg->{attach} }, {
Type => 'application/octet-stream',
Filename => "$param.$bestext",
Data => $data,
Disposition => 'attachment',
Encoding => 'base64',
};
$piece = MIME::Lite->new (
Type => "multipart/$container",
Encoding => '7bit',
);
>>> HOW DO I PUSH $piece ONTO $msg ?? <<<
# End of main program. Email must be completed by this stage..
send ($msg);
sub send {
my $msg = @_;
my $ml = MIME::Lite->new(
To => $msg->{To},
From => $msg->{From},
Subject => $msg->{Subject},
Data => $msg->{body},
Encoding => 'quoted-printable',
);
foreach my $a (@{ $msg->{attach} || [] }) {
$ml->attach( %$a );
}
}
More information about the london.pm
mailing list