发送的电子邮件中的附件为空白
我已使用此脚本发送文本文件,电子邮件带有附件,但当我打开附件时,它是空白的。知道为什么吗?我错过了什么吗?谢谢
#!/usr/bin/perl -wl
my $msg = MIME::Lite->new(
From => 'xxx.net',
To => 'xxx.com',
Subject => 'Report',
Type => 'multipart/mixed',
)or die "Error creating multipart container: $!\n";
$msg->attach(
Type => 'TEXT',
Data => " Please check the attached file.",
)or die "Error adding the text message part: $!\n";
$msg->attach (
Type => 'text/plain',
Path => '/myfile/file1',
Filename => 'result.txt',
Disposition => 'attachment'
)or die "Error adding the attached file part: $!\n" ;
$msg->send;
I have used this script to send the text file, the email go out with attachment but when I open the attached file it's blank. any idea why? did I miss anything. thx
#!/usr/bin/perl -wl
my $msg = MIME::Lite->new(
From => 'xxx.net',
To => 'xxx.com',
Subject => 'Report',
Type => 'multipart/mixed',
)or die "Error creating multipart container: $!\n";
$msg->attach(
Type => 'TEXT',
Data => " Please check the attached file.",
)or die "Error adding the text message part: $!\n";
$msg->attach (
Type => 'text/plain',
Path => '/myfile/file1',
Filename => 'result.txt',
Disposition => 'attachment'
)or die "Error adding the attached file part: $!\n" ;
$msg->send;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对
attach
的参数有点困惑。来自精细手册:Path
是您要附加的文件的完整路径,Filename
是您希望接收者看到的该文件的名称。我想你想要这个:
You're a little confused about the arguments to
attach
. From the fine manual:The
Path
is the full path to the file that you want to attach, theFilename
is the name that you want to receiver to see for that file.I think you want this: