简体   繁体   English

如何使用脚本中文件路径的变量在FreeBSD中发送邮件?

[英]How to send mail in FreeBSD using variables of file paths in scripts?

We used to have a mail command which worked on Solaris platform, the command was 我们曾经有一个在Solaris平台上工作的mail命令,该命令是

mail -t $MAILTO < ${SCRIPTROOT}abc.txt

abc.txt is the file name which was used as subject. abc.txt是用作主题的文件名。

Now we migrated to FreeBSD and the mail is not coming. 现在我们迁移到FreeBSD了,邮件也没有了。 I removed the -t flag, the mail came, but the text came in body of mail. 我删除了-t标志,邮件来了,但是文本出现在邮件正文中。 If I put -s flag on abc.txt , the complete path of abc.txt is showing. 如果将-s标志放在abc.txt上,则显示abc.txt的完整路径。

If I understand you correctly, you want the content of abc.txt as the subject of the mail. 如果我对您的理解正确,则希望将abc.txt的内容作为邮件的主题。 That would be achieved by the following: 这将通过以下方式实现:

mail -s "`cat abc.txt`" ${RECIPIENT} < ${FILE_WITH_MAIL_BODY}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM