How To: IMAP folders & Maildir filtering

jeroman8

Well-Known Member
Mar 14, 2003
410
0
166
To filter mail to Maildir accounts IMAP subfolders (!) you need to
add this to exim conf under central_filter:

It say already:
file_transport = address_file

Put this below:
directory_transport = address_file

This is because you are not writing to a file here, you're writing to a folder
and need the "name" of the new file to be something.

You can use the cpanel filter interface as usally.
Under "destination" write your path to the e-mail accounts "new" folder och
the e-mailaccounts subfolders "new" folder.

For example:
Destination: /home/domain44/mail/domain44.com/support_email/.urgent/new/

support_email = [email protected]
.urgent = IMAP folder

The "/" in the end is important.

I just tested this after a client wanted to have the server/exim to do the filtering
and it works perfectly on this cpanel/exim server with maildir.
 

WebspaceUK

Member
Jan 3, 2004
5
0
151
London, UK
I just tried this and this happened..

Filter Trace



Filter Trace Results:
Condition is true: $header_to: is just-one(at)habboremix.net
Return-path copied from sender
Sender = hr(at)serv.webspaceuk.com
Recipient = hr(at)serv.webspaceuk.com
Testing Exim filter file "/etc/vfilters/habboremix.net"

Save message to: /home/hr/mail/habboremix.net/contact.uk/.James/new/ 0660
Filtering set up at least one significant delivery or other action.
No other deliveries will occur.

And on my IMAP it just showed as a new email in the inbox, not in James. Any idea's why?

Thanks!
 

jeroman8

Well-Known Member
Mar 14, 2003
410
0
166
jeroman8

Just send a regular mail to the account with the words or whatever you filter
and "tail -f /var/log/exim_mainlog" to see what it say there.

Also, I do not have the permission set in the filter, 0660.
Don't think it matter though.
 

Southpaw018

Registered
Aug 13, 2006
1
0
151
Are you sure the correct line is:
directory_transport = address_file

Everywhere I'm looking, it says the line should be
directory_transport = address_directory


Please advise. I don't have access to the Exim conf on my server, and I will probably only be able to have my host change it once.
 

Onyx

Member
May 28, 2006
8
0
151
Working Version

Using all the info above we were able to create a working configuration that handles both local mail from the same server as well as mail from an external location. Some of things we changed may be overkill, but this is the way we got it working:

Working in three files:

/etc/exim.conf
/etc/exim.conf.local
/etc/exim_outgoing.conf


In all files, we found and replaced

Code:
file_transport = file_directory
with:

Code:
file_transport = file_directory
directory_transport = address_directory
With a hint from this thread on the Exim list we added an address_directory transport, right below the address_file thransport:
Code:
address_directory:
  debug_print = "T: address_directory for [email protected]$domain"
  driver = appendfile
  envelope_to_add = true
  return_path_add = true
  check_string = ""
  escape_string = ""
  maildir_format
We'll be stripping down this config to see which parts are essential and which aren't. But filters are triggered properly from both outside and internal email addresses.
 

Onyx

Member
May 28, 2006
8
0
151
Enable Directory Transport - Instructions

In follow up to my last post in this thread, I have a pretty easy alternative that so far seems to be working. The original changes worked fine but were overwritten with each Exim upgrade.

By using the Exim Configuration editor located in WHM, we can create permanent additions to the configuration setup quickly and easily.


  1. Go to WHM > Exim Configuration Editor
  2. Switch to Advanced Mode
  3. Scroll down to the editable text box where you will find a "mysystem_aliases" directory. This is in the "DIRECTORS CONFIGURATION" section.
  4. Add the following:
    Code:
    mycentral_filter:
    #!!# filter renamed allow_filter
      driver = redirect
      allow_filter
      no_check_local_user
      file = /etc/vfilters/${domain}
      file_transport = address_file
      directory_transport = address_directory
      pipe_transport = virtual_address_pipe
      reply_transport = address_reply
      retry_use_local_part
      user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
      no_verify
  5. Now, scroll down to the text box directly above "RETRY CONFIGURATION". This will probably be empty, and can be used to add custom transports to the end of the "TRANSPORTS CONFIGURATION" section.
  6. Add the following there:
    Code:
    address_directory:
      debug_print = "T: address_directory for [email protected]$domain"
      driver = appendfile
      envelope_to_add = true
      return_path_add = true
      check_string = ""
      escape_string = ""
      maildir_format
  7. All set! Now save the changes and restart Exim by submitting the form. Check for problems starting up just in case.

We have yet to test these changes to see if they hold up to Exim/CPanel updates. However from my understanding of the Exim Configuration Editor, it should do the trick.