在Postfix(或Cyrus IMAP)上监视邮件传递

有邮件服务器基于Postfix。 我需要监视哪些消息被传送给最终用户? 而哪些不是。 在处理每条消息时,我需要从XML格式的附件中获取一些信息。 我怎样才能以这种方式监控交付信息?

谢谢!

我需要监视哪些消息被传送给最终用户? 而哪些不是

所有失败和成功的交付logging到/var/log/maillog 。 你可能想要使用Nagios的check_logfiles插件:

 Name : check_logfiles Arch : x86_64 Version : 3.4.2 Release : 1.el5.rf Size : 39 k Repo : rpmforge Summary : Logfile check plugin for nagios URL : http://sourceforge.net/projects/check-logfiles License : GPL Description: check_logfiles is a plugin for Nagios which searches for patterns in logfiles. It is capable of scanning : multiple logfiles and their rotated ancestors in a single run. 

定义一个命令来检查这个文件:

 command[check_postfix]=/usr/bin/sudo /usr/local/nagios/libexec/check_logfiles \ --tag=postfix \ --logfile=/var/log/maillog \ --warningpattern="warning" \ --criticalpattern="critical" 

示例结果:

好 – 没有错误或警告| postfix_lines = 0 postfix_warnings = 0 postfix_criticals = 0 postfix_unknowns = 0


在处理每条消息时,我需要从XML格式的附件中获取一些信息

你的意思是你想过滤一些附件文件types。 如果是这样,看看mime_header_checks指令。

通过/etc/postfix/main.cf下行添加到/etc/postfix/main.cf来定义一个标头检查:

 mime_header_checks = regexp:/etc/postfix/mime_header_checks 

附加一些文件扩展名到这个文件:

 /name=[^>]*\.(exe|bat|bin|sh)/ REJECT 

重新启动Postfix并使用mutttesting:

 echo "hello" | mutt -s "Test mail" -a attach.sh [email protected] 

您应该在日志文件中看到被拒绝的消息:

11月9日11:35:08 199 postfix / cleanup [27318]:F1649BFB0176:reject:header Content-Disposition:attachment; 本地文件名=“attach.sh”; 从=到=:5.7.1邮件内容被拒绝