[Exim] suffix-to-folder delivery

Pàgina inicial
Delete this message
Reply to this message
Autor: Kirill Miazine
Data:  
A: exim-users
Assumpte: [Exim] suffix-to-folder delivery
Greetings exim-users,

Users on my private system access their messages using IMAP. The IMAP
server is from the Courier project, messages are stored in Maildirs.

One useful feature is the ability to directly deliver messages addressed
to user-foo to user's INBOX.foo (that is to $HOME/Maildir/.foo/) if such
exists and to INBOX otherwise (without using Exim filters). With Exim
that is very easy.

A number of Exim users found the router that does the job very
interesting. Many Exim users use Courier IMAP too, so this post may be
useful for some of you.

Here come the relevant parts of exim.conf.

# Macro definitions

#
# Path to Courier's userdb. Usernames are of the form:
# domain-username
#
COURIER_UDB = /etc/userdb.dat

#
# COURIER_UIL will return user data in the form that is suitable for the
# ${extract...} operator:
#   uid=1510 gid=1510 home=/data/mail/krot.org/57 quota=0
#
COURIER_UIL = ${tr\
    {${lookup{$domain-$local_part}dbmnz{COURIER_UDB}{$value}fail}}\
    {|}{ }}


#
# Translate the suffix to a "safe" folder name.
#
COURIER_S2D = ${sg\
    {${sg\
        {${sg\
            {${substr_1:$local_part_suffix}}\
            {[^a-z0-9_.+-]}{}}}\
        {^\\.+}{}}}\
    {\\.+}{.}}



# Routers

courier_suf2dir:
    driver = redirect
    local_part_suffix = -*
    address_data = COURIER_UIL
    data = ${if exists\
            {${extract{home}{$address_data}{$value/Maildir}}/.COURIER_S2D/cur}\
        {${extract{home}{$address_data}{$value/Maildir}}/.COURIER_S2D/}fail}
    directory_transport = courier_dir
    no_verify


courier_maildir:
    driver = redirect
    domains = +courier_domains
    local_part_suffix = -*
    local_part_suffix_optional
    address_data = COURIER_UIL
    data = ${extract{home}{$address_data}{$value/Maildir/}}
    directory_transport = courier_dir



# Transports

courier_dir:
    driver = appendfile
    maildir_format
    maildir_tag = ,S=$message_size
    create_file = belowhome
    create_directory
#    quota = ${extract{quota}{$address_data}}
#    quota_directory = ${extract{home}{$address_data}{$value/Maildir}}
#    quota_size_regex = ,S=(\d+)
    return_path_add
    envelope_to_add
    message_prefix =
    message_suffix =
    user = ${extract{uid}{$address_data}}
    group = ${extract{gid}{$address_data}}


Bye,

--
Kirill Miazine
mailto:km@krot.org
http://km.krot.org/