Perl 和MIME::Lite - 为什么我的 .txt 附件是空白的?

发布于 2024-10-17 13:13:45 字数 921 浏览 4 评论 0原文

我已经使用 MIME::Lite 有一段时间了,并且已经到目前为止没有任何问题。

我正在尝试附加 .txt 文件,但该文件(发送后)内部没有任何内容。

我知道该文件中有一些内容,因为我正在同一脚本中创建 .txt 文件。我知道该文件在哪里并且可以看到其内容,但是当我告诉 MIME::Lite 附加 .txt 文件时,电子邮件仅包含文件名并且只有 64 字节。

以下是我的脚本的 MIME::Lite 部分的代码:

$msg = new MIME::Lite(From => $from,To => $to,Subject => $subject,Data => "Data",Type => "multipart/mixed",); 
$msg->attach(Type => 'TEXT', Data => @message);
$msg->attach(Type => 'TEXT', Path => $stat_file);
$msg->send();

其中 $stat_file = /in/some/dir/cheese/txt/somefile.txt< /code>

除了第三行之外,一切正常。它正确地找到&附加我指向的文件,但当它到达我的电子邮件时,它是一个 64 字节的空白 .txt 文件。

我已经尝试了这段代码前三行的几种变体,但不知道我错过了什么。

有人看到这个脚本按照解释执行的原因吗?

I've been using MIME::Lite for a short while now and have had no issues until now.

I'm trying to attach a .txt file, but the file (after sent) has no content inside of it.

I know the file has something in it because I'm creating the .txt file within the same script. I know where the file is and can see its contents, but when I tell MIME::Lite to attach the .txt file, the email comes in with just the file name and is only 64 bytes.

Here's the code for the MIME::Lite portion of my script:

$msg = new MIME::Lite(From => $from,To => $to,Subject => $subject,Data => "Data",Type => "multipart/mixed",); 
$msg->attach(Type => 'TEXT', Data => @message);
$msg->attach(Type => 'TEXT', Path => $stat_file);
$msg->send();

Where $stat_file = /in/some/dir/cheese/txt/somefile.txt

Everything works fine except for the 3rd line. It is correctly finding & attaching the file that I'm pointing to, but when it hits my email, its a blank .txt file of 64 bytes.

I've tried several variations of each of the first 3 lines of this code, but don't know what I'm missing.

Anyone see a reason that this script would perform as explained?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慢慢从新开始 2024-10-24 13:13:45

您说您正在程序中创建 $stat_file 指向的文件,对吧?也许您还没有关闭该文件的文件句柄,并且可能它没有被刷新到磁盘?

You say you're creating the file pointed to by $stat_file in your program, right? Maybe you haven't closed the filehandle to that file, and possibly it's not being flushed out to disk?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文