Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

There's mail server based on Postfix. I need to monitor which messages are delivered to end-user? and which are not. In processing of each message I need to get some information from its attachment in XML format. How can I monitor delivery messages this way?

Thanks!

share|improve this question

1 Answer 1

I need to monitor which messages are delivered to end-user? and which are not

All failed and successful deliveries are logged to /var/log/maillog. You may want to use the Nagios's check_logfiles plugin:

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.

Define a command to check this file:

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

A sample result:

OK - no errors or warnings|postfix_lines=0 postfix_warnings=0 postfix_criticals=0 postfix_unknowns=0


In processing of each message I need to get some information from its attachment in XML format

Do you mean you want to filter some attachment file types. And if so, take a look at the mime_header_checks directive.

Define a header checks by adding the following line to /etc/postfix/main.cf:

mime_header_checks = regexp:/etc/postfix/mime_header_checks

Append some file extensions to this file:

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

Restart Postfix and test with mutt:

echo "hello" | mutt -s "Test mail" -a attach.sh your.email@domain.com

you should see the rejected message in the log file:

Nov 9 11:35:08 199 postfix/cleanup[27318]: F1649BFB0176: reject: header Content-Disposition: attachment; filename="attach.sh" from local; from= to=: 5.7.1 message content rejected

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.