develooper Front page | perl.pep | Postings from November 2014

Where is the attached file opened with Email::MIME?

Thread Next
Octavian Rasnita
November 15, 2014 22:51
Where is the attached file opened with Email::MIME?
Message ID:

I couldn't find a way of using Email::MIME::Kit to compose a message by 
adding the file attachments on the fly that allow adding more or less files 
for different recipients, so I am trying to use Email::MIME for this.

But I found that Email::MIME brokes the pdf file attachments by increasing 
their size.
I use the code below as an example of how I try to add the pdf attachment.
Is there something wrong in my code or there is a bug in Email::MIME?
I ran it under Windows XP using ActivePerl 5.14.

use strict;
use warnings;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use utf8;

open my $in, '<', "bogus-report.pdf";
binmode $in;
my $pdf = do { local $/; <$in> };

my $email = Email::MIME->create(
    header_str => [
        From => 'Oct Râş <>',
        To => 'Me too <>',
        Subject => 'Subj ţţţ',
    parts => [
            body_str => "Hello there",
            attributes => {
                content_type => "text/plain",
                charset => "US-ASCII",
                encoding => "quoted-printable",
            body => $pdf,
            attributes => {
                content_type => "application/pdf",
                name => "bogus-report.pdf",
                filename => "bogus-report.pdf",
                encoding     => "quoted-printable",



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About