Re: [exim] Must $home be prepended to relative directories i…

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Magnus Holmgren
Date:  
À: exim-users
Sujet: Re: [exim] Must $home be prepended to relative directories in Exim filters?
To follow up and share, here is my new directory setting:

  directory = \
    ${if eq{${lc:$address_file}}{inbox}\
       {$home/Maildir}\
       {${if match {$home/Maildir/.${perl{utf7encode}\
                                         {${sg{$address_file}{\/}{.}}}}}\
               {.+}\
           {${if exists {$0} {$0}{$home/Maildir}}}\
         }\
       }\
     }


A match condition is used solely to capture the derived directory name so that
the long expression doesn't have to be repeated. If the directory doesn't
exist, the mail is delivered to the inbox instead of failing delivery. Of
course, there is no guarantee that the result is a maildir, but it at least
gives some protection against mistakes.

The utf7encode function looks like this (Unicode::IMAPUtf7 is available from
CPAN):
use Unicode::IMAPUtf7;

sub utf7encode($) {
    my $t = Unicode::IMAPUtf7->new();


    return $t->encode($_[0]);
}


IMHO the documentation should be updated to more clearly state that
$address_file can be used in the expansion of file_transport and
directory_transport. I use these settings in my userforward router
(user_directory is the transport containing the directory setting above):

  file_transport = ${if eq{${length_1:$address_file}}{/}\
             {address_file}{user_directory}}
  directory_transport = ${if eq{${length_1:$address_file}}{/}\
                   {address_directory}{user_directory}}
  # and of course:
  no_filter_prepend_home


So absolute path names cause the more common transports to be used, and
appending to mbox files is possible.

--
Magnus Holmgren
holmgren@???