Background
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:
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.
Expectation
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?
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?
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.