Mail ::带有附件的Sendmail,并将Perlembedded到Bash脚本中

1>我想在BASH脚本中embedded下面的Perl脚本,并且Message应该从message.txt文件中读取。 如何实现这一点?

use Mail::Sendmail; %mail = ( To => '[email protected]', From => '[email protected]', Message => "This is a very short message" ); sendmail(%mail) or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log; 

2>如何通过Perl脚本附加日志文件?

如果你打算用bash脚本来做,那么也许你可以不用Perl。 在你的bash脚本中有这样的东西:

 mutt -F $HOME/.muttrc.me -x -a attachment.file -- [email protected] < message.txt 

这需要mutt ,你可以有一个自定义的.muttrc文件(在这种情况下是$ HOME / .muttrc.me)来控制From:头:

 my_hdr From: "Me Here" <[email protected]> my_hdr Reply-To: [email protected] 

@adamo告诉我的工作正常,如果有很多收件人,这里可能还有一个更好的方法:

 cat message.txt | mail -a 'From: [email protected]' -a 'To: [email protected]' -s 'Subject for the message' [email protected]