[exim] Setting a prefix for 'save' with maildir delivery and…

Top Page
Delete this message
Reply to this message
Author: Adam Nielsen
Date:  
To: exim-users
Subject: [exim] Setting a prefix for 'save' with maildir delivery and .forward filters
Hi everyone,

I think I've figured out how to do this, but I'd just like to check
whether this is acceptable or whether there's a simpler way.

Basically I have a .forward file like this:

  # Exim filter
  if $header_subject: contains "test" then
    save .test/
  endif


With the idea being any message arriving with the word "test"
in the subject will be saved in the user's maildir tree, under
the "test" folder (which appears in the filesystem as
/home/username/.maildir/.test/)

The transport in exim.conf was originally like this:

  address_directory:
    driver = appendfile
    maildir_format = true
    directory = ${home}/.maildir/


However this simply delivered all mail into the user's main inbox,
ignoring what was specified in the "save" command. I saw a post on the
mailing list which suggested changing "directory" to this:

    directory = ${home}/.maildir/${address_file}


But that post complained that the message just disappeared. The log
file showed that the message was in fact being delivered somewhere else:

1GHDvj-0005p1-AA => /home/username/.maildir//home/username/.test/

Which is not surprising, as the manual says that the "save" command will
prefix ${home} if a relative path is specified. I could not find how to
change the path prepended from ${home} to something else, but I did
discover a regular expression that appears to work, by removing ${home}
from the start of the path (effectively undoing the prefix that 'save'
inserted.)

directory = ${home}/.maildir/${sg{${address_file}}{^${home}/(.*)\$}{\$1}}

This delivers it to the correct directory:

1GHE58-0005qw-Na => /home/username/.maildir/.test/

But I have a sneaking suspicion that there's an easier way to do this.
Is there, or is this way fine?

Thanks,
Adam.