I'm running Ubuntu 16.04 LTS on a virtual machine. It is the mail server for a small medical clinic. We are trying to move mail filtering from the client-side to the server-side, and I am having difficulty with $HOME/.mailfilter rule files.

I've been reading various copies of the man-page at multiple locations, but there is not much information about turning on logging. An example of the data that I am working from can be found here: Maildrop Filter Man Page

Current Setup

At the moment, my directory structure looks like this: enter image description here

The three files that I created to contain the filter rules contain very simple instructions:

logfile "/var/log/maildropfilter.log"
log "Executing code in {file_path}"

Naturally, I change "{file_path}" to be whatever file I'm currently in. My hope is that if the rule file is executed that the logfile will have a statement that says "Executing code in {file_path}", and I will know which of the three files to start putting control logic into.


According to the documentation, or rather my interpretation of it, after receiving an email to my email account for user jaredclemence, I should see the following in my log file:

Executing code in /etc/courier/maildroprc
Executing code in /home/jaredclemence/.mailfilter

I should not see any reference to the third file in the Maildir, because this file is not $HOME/.mailfilter, which is the file that the documentation points to. I created this file just in-case $HOME references the root of the Maildir instead the root of the user account's home folder.

Current Result

The trouble is, when I send an email to the user jaredclemence from outside the network, the email does get received, but the log file is empty.

What am I doing wrong?

  1. Is there something special that I have to do in order to register my filter rules, or is having the file in the correct location all that is required?

  2. If having the file in the correct location is all that is required, then what is wrong with the code that I have written, which sets the logfile and outputs a message to the log with the log command?

All help is appreciated.

Update 2018-01-04 10:17

I read the maildrop man-file and learned more about the various modes that it will run in, and identified that one of the three modes does not use the .mailfilter rules.

Noting that there is a manual mode, I executed the maildrop command in manual mode to see if the logfile were activated and utilized.

After running the maildrop command manually, I verified the following output:

Executing commands from /home/jaredclemence/.mailfilter
Date: Thu Jan  4 09:37:05 2018
From: Synegi Inc <klally@synegi.com>
Subj: Wishing You a Happy New Year from Synegi!
File: /var/mail/jaredclemence                                          (29594)

This is interesting, because the global rule file is never activated. It is also interesting because it delivers the mail to an mbox at /var/mail/jaredclemence, which is not the Maildir.

This suggests one of two things. Either the maildrop program is not used as the local delivery agent, or a configuration file changes the delivery location when the maildrop program is run in the 'Embedded Mode', which is the only mode of the three that does not execute the .mailfilter file instructions.

From here, I have started reading man-pages for trace(8), postfix(1), and local(8) to see if I can track down which program is being used by the mail delivery agent.


After much research and searching, I have discovered that my system is not using maildrop for delivery.

If you are having the same question, first identify which mail delivery agent your system is using.

Start with your SMTP server. Mine is Postfix.

Postfix uses it's own local delivery agent in a process called local(8). In the file /etc/postfix/main.cf, look for a variety of references to any of the local(8) handoff parameters. The two most prominent would probably be mailbox_transport or virtual_transport (the difference depends on whether the people who receive mail have accounts with home directories or if an account is maintained virtually).

If these parameters are not set, then postfix is probably handling its own local delivery, and as far as I can tell, postfix does not do inspection based redirection and delivery to specific mailboxes, only from one email address to another based on a series of forwarding or alias addresses.

So, if you are trying to implement advanced filtering with Courier or Dovecot-LDA or Dovecot-LMTP, then you will need to tell Postfix using the mailbox_transfer or virtual_transfer settings which program to call.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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