Friday 3 June 2016

maildrop and postfix

This is quite a short entry, it's mainly to help out anybody that needs to debug the same as me, as it took me a while to find the right information online.
If you're using postfix, and use maildrop you probably also use mailfilter rules to move your mail into the relevant folders on IMAP for you. Well if things don't go where you expect, or don't seem to drop into the folders you need to debug. Telling maildrop to debug and what to look for isn't exactly intuitive.
I'm using postfix, maildrop and ispconfig, so your config may be a little different, but the debugging should be the same. In your postfix master.cf you should have your maildrop line, something like:
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d vmail ${extension} ${recipient} ${user} ${nexthop} ${sender}
Which puts it into delivery mode with user vmail. So in your /home/vmail (or whatever user folder it's set to) will be your .mailfilter generic file. It's in here you can setup the logging location:
logfile "/tmp/maildrop.log"
VERBOSE="9"
Seemed to work nicely for me, it was only a temporary log I wanted to look at. No need to restart postfix as it's called on the fly. Reading that file you'll see something like:
Date: Fri Jun  3 20:10:51 2016
From: Homebase <homebase@homebaselife.com>
Subj: Be BBQ ready
File: /home/mydomain/myuser/.                                (154696)
Which in this case shows the email was dropped into the default inbox folder. If it was filtered into an alternative folder you'd see:
 
Date: Fri Jun  3 20:10:51 2016
From: Homebase <homebase@homebaselife.com>
Subj: Be BBQ ready
File: /home/mydomain/myuser/./SOMEFOLDER/                                (154696)
Or similar to that. Easy!
Also if you want to log bits in the filter itself, open up the .mailfilter for your user account, and add in lines like:
log "== some log words =="
And that will literally log that to the file. Good to check your if conditions are working or to dump out some temporary fields.

That's it really!
 
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.