[英]Save mail message as a file on Linux using sendmail
I have an application running on several RHEL 5.8 systems which monitors and alerts (via email). 我有一个在多个RHEL 5.8系统上运行的应用程序,该系统监视和警报(通过电子邮件)。 I need to create a durable log of these alerts locally on each node. 我需要在每个节点上本地创建这些警报的持久日志。
I think the easiest way to do this would be to add a local email user to the alerts and then use mailbox settings or a script (if needed) to save each message on a local filesystem 我认为最简单的方法是将本地电子邮件用户添加到警报中,然后使用邮箱设置或脚本 (如果需要)将每封邮件保存在本地文件系统中
I would settle for message body dumped to a text file (one file per email.) 我希望将邮件正文转储到文本文件(每封电子邮件一个文件)。
It would be better if it could extract time, host, subject, & body as seperate fields for consumption by an open source log reader. 最好将时间,主机,主题和正文作为单独的字段提取出来,以供开放源日志阅读器使用。
My systems are using sendmail 8.1 and I would prefer to stick with it, although I also have postfix 2.3.3 available. 我的系统正在使用sendmail 8.1,尽管我也有可用的postfix 2.3.3,但我还是希望坚持使用它。
As you reported your sendmail uses procmail as local mailer => create special OS user account (eg log_user) and use ~log_user/.procmailrc
to instruct procmail to deliver messages to maildir folder. 如您所报告的,sendmail使用procmail作为本地邮件程序=>创建特殊的OS用户帐户(例如log_user),并使用~log_user/.procmailrc
指示procmail将邮件传递到maildir文件夹。
~log_user/.procmailrc 〜LOG_USER / .procmailrc文件
# deliver ALL messages to ~/maillog/ maildir.
# see "man procmailex" for email sorting examples
:0
maillog/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.