Perl Net::使用html格式时SMTP电子邮件大小问题
我正在用perl通过SMTP发送电子邮件。该电子邮件包含一些表格、链接和列表。 我使用的是html格式的数据Perl Net::使用html格式时SMTP电子邮件大小问题,perl,email,smtp,Perl,Email,Smtp,我正在用perl通过SMTP发送电子邮件。该电子邮件包含一些表格、链接和列表。 我使用的是html格式的数据 $smtp->data(); $smtp->datasend("MIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n<H1>"); $smtp->datasend("$message"); ... $smtp->dataend(); $smtp->quit; 有时电子邮件大
$smtp->data();
$smtp->datasend("MIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n<H1>");
$smtp->datasend("$message");
...
$smtp->dataend();
$smtp->quit;
有时电子邮件大小太大,大约1mb。是否有任何方法可以在不减少数据量的情况下减少电子邮件的大小。我不希望邮件作为附件。我使用outlook打开邮件。您应该使用outlook通过电子邮件发送附件
#!/usr/bin/perl
use Mail::Sender
$to = 'email1@example1.com,email2@example2.com';
$sender =new Mail::Sender {
smtp => 'smtp.mailserver.com',
from => 'script@somedomain.com,
});
$subject = 'This is a Test Email';
$sender->OpenMultipart({
to => "$to",
subject => "$subject",
});
$sender->Body;
$sender->SendLineEnc("Test line 1");
$sender->SendLineEnc("Test line 2");
$sender->Attach({
description => 'Test file',
ctype => 'application/x-zip-encoded',
encoding => 'Base64',
disposition => 'attachment;
filename="File.zip"; type="ZIP archive"',
file => "$file",
});
$sender->Close();
exit();
或者使用MIME::Lite
use MIME::Lite;
$msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
) or die "$!\n";
### Add the ZIP file
$msg->attach (
Type => 'application/zip',
Path => $my_file_zip,
Filename => $your_file_zip,
Disposition => 'attachment'
) or die "Error adding $file_zip: $!\n";
### Send the Message
$msg->send('smtp', $mail_host, Timeout=>60);
我使用gzip压缩了它,但问题是如何将它发送到outlook,以便它正确显示。outlook可以足够智能,以内联方式显示它。许多MUA将内联显示一个gzip文本文件。感谢您的回答。我刚刚修改了一些数据以减小大小。好的。但你试过上述解决方案吗?它有用吗?因为我没有尝试过。我没有尝试过,因为我不希望它成为附件。但是附件也可以与smtp一起使用,我在前面的一个代码中使用了它。是的,文本附件可以与smtp一起使用。但对于zip文件或二进制文件附件,我认为您需要上述模块。请更新您的问题,说明您不希望将其作为附件。