Perl 和MIME::Lite - 为什么我的 .txt 附件是空白的?
我已经使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说您正在程序中创建
$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?