如何使用 Perl 将多个文件附加到电子邮件?
我很难相信这个问题在 SO 上不存在,但我找不到 Perl 的实例或类似的实例......
无论如何,我应该使用什么 Perl 模块将多个文件附加到一封电子邮件?
目前,我正在使用此代码发送带有单个附件的电子邮件,但我不知道如何修改它以处理多个附件:
my $mail_fh = \*MAIL;
open $mail_fh, "|uuencode $attachment $attachment |mailx -m -s \"$subject\" -r $sender $recipient";
print $mail_fh $message;
close($mail_fh);
可以修改此代码块以处理多个附件吗?或者我是否必须使用特殊的模块来实现这一点?如果是这样,该模块是什么?我将如何编写它的脚本?
感谢您的帮助!
I find it hard to believe that this question doesn't exist on SO, but I couldn't find an instance or one similar for Perl....
Anyway, what Perl module should I use to attach multiple files to an email?
Currently, I'm using this code to send an email with a single attachment, but I couldn't figure out how to modify it to handle multiple attachments:
my $mail_fh = \*MAIL;
open $mail_fh, "|uuencode $attachment $attachment |mailx -m -s \"$subject\" -r $sender $recipient";
print $mail_fh $message;
close($mail_fh);
Can this code block be modified to handle multiple attachments? Or do I have to use a special module to pull this off? If so, what is the module and how would I script it out?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最终使用
MIME::Lite
找到了一个示例 这里示例用法:
I ended up going with an example using
MIME::Lite
found hereexample usage:
请参阅 Email::Stuff 中的
attach_file
或 Email::MIME 如果您需要更多控制。See
attach_file
in Email::Stuff, or Email::MIME if you need more control.尽管评价参差不齐,但我发现 Mail::Sender (而且它是朋友 < a href="http://search.cpan.org/~dmuey/Mail-Sender-Easy/" rel="nofollow">Mail::Sender::Easy)非常好用且简单易用,并且看起来它可以处理多个附件。
我发现 Mail::Internet< 中的界面非常烦人/a>.
不过,任何事情都应该比上面的更好。 :-)
Despite mixed ratings, I've found Mail::Sender (and it's pal Mail::Sender::Easy) darn good and straightforward to use, and looks like it can handle multiple attachments.
I found the interface to be extremely annoying in Mail::Internet.
Anything should be better than what you have above, though. :-)