当我使用Email::MIME将附件(约110KiB)与此脚本一起发送时,为什么附件(约110KiB)被分成10部分(约11KiB)?
#!/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 $@;
发布于 2010-05-02 00:25:30
我可以为您提供一个解决方法:使用MIME::Lite
发布于 2011-02-24 08:34:09
我在我的Perl脚本中使用了MIME::Lite和Net::SMTP::TLS (使用TLS而不是SSL,因为与smtp.gmail.com的连接不使用SSL),通过gmail帐户发送带有电子表格附件的电子邮件,电子表格附件被分解成多个10kb的文件。
解决方案是将Net::SMTP::TLS替换为Net::SMTP::TLS::ButMaintained,这是我最初没有看到的。较新的TLS模块运行良好。
https://stackoverflow.com/questions/2729228
复制相似问题