2010-04-28 33 views
0

當我使用Email::MIME通過此腳本發送附件(約110KiB)時,爲什麼會將附件分成10份(大約11KiB)?爲什麼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 => '[email protected]', To => '[email protected]', Subject => 'subject', ], 
    parts => [ @parts ], 
); 

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

回答

0

我可以爲您提供一個解決辦法:使用MIME ::精簡版,而不是

1

我不得不使用MIME::LiteNet::SMTP::TLS(使用TLS而非SSL類似的情況,因爲連接到smtp.gmail.com不工作與SSL)在我的Perl腳本發送電子郵件與電子表格附件通過一個Gmail帳戶,從而電子表格附件被分解成多個10kb文件。

解決方案是用Net::SMTP::TLS::ButMaintained替換Net :: SMTP :: TLS,我最初並沒有看到它。較新的TLS模塊效果很好。

+0

非常感謝你這麼做。 – Kungi 2014-01-08 09:07:52

相關問題