Why does Email::MIME split up my attachment?

Posted by sid_com on Stack Overflow See other posts from Stack Overflow or by sid_com
Published on 2010-04-28T12:07:57Z Indexed on 2010/05/01 16:27 UTC
Read the original article Hit count: 394

Filed under:
|
|

Why does the attachment(ca. 110KiB) split up in 10 parts(ca. 11KiB) when I send it with this script using Email::MIME?

#!/usr/bin/env perl
use warnings; use strict;

use Email::Sender::Transport::SMTP::TLS; 
my $mailer = Email::Sender::Transport::SMTP::TLS->new(
    host => 'smtp.my.host',
    port => 587,
    username => 'username',
    password => 'password',
);

use Email::MIME::Creator;
use IO::All;
my @parts = (    
    Email::MIME->create(
    attributes => {
        content_type => 'text/plain',
        disposition  => 'inline',
        encoding     => 'quoted-printable',
        charset      => 'UTF-8',
    },
    body => "Hello there!\n\nHow are you?",
    ),
    Email::MIME->create(
    attributes => {
        filename     => "test.jpg",
        content_type => "image/jpeg",
        disposition  => 'attachment',
        encoding     => "base64",
        name         => "test.jpg",
    },
    body => io( "test.jpg" )->all,
    ),
);
my $email = Email::MIME->create(
    header => [ From => 'my@address', To => 'your@address', Subject => 'subject', ],
    parts  => [ @parts ],
);

eval {
    $mailer->send( $email, {
        from => 'my@address',
        to   => [ 'your@address' ],
    } );
};
die "Error sending email: $@" if $@;

© Stack Overflow or respective owner

Related posts about perl

Related posts about email