# This transport is used for handling file addresses generated by alias
# or .forward files if the path ends in "/", which causes it to be treated
# as a directory name rather than a file name.

address_directory:
  debug_print = "T: address_directory for $local_part@$domain"
  driver = appendfile
  envelope_to_add
  return_path_add
  # This is enabled by default, but just to be explicit..
  create_directory
  allow_symlink
  maildir_format
  maildir_use_size_file
  #
  # Make sure we only have one quota for the whole mailbox
  #
  quota_directory    = ${home}/Maildir/
  #
  # The maildir++ spec says that message size should be tagged to the end of
  # each maildir file, so we better make sure we do it.
  #
  maildir_tag = ,S=$message_size
  quota_size_regex = ,S=(\d+)
  # 
  # Work out if this is a symbiosis domain
  # and See if a per-domain quota has been set.
  #  a) Use the per-user quota if set
  #  b) Use the per-domain quota if set
  #  c) Use the site-wide quota if set
  #  d) Use a zero quota
  #
  # If the quota is in the correct format, use a lookup table to find the
  # correct multiplier for the integer, and mulitply it up appropriately.
  #
  quota = ${if match{ \
            ${if exists{VHOST_DIR/${domain}/VHOST_MAILBOX_DIR/${local_part}/quota} \ 
              {${readfile{VHOST_DIR/${domain}/VHOST_MAILBOX_DIR/${local_part}/quota}}} \
              { \
                ${if exists{VHOST_DIR/${domain}/VHOST_CONFIG_DIR/mailbox-quota} \
                  {${readfile{VHOST_DIR/${domain}/VHOST_CONFIG_DIR/mailbox-quota}}} \
                  { \
                    ${if exists{ETC_DIR/exim4/mailbox-quota} \
                      {${readfile{ETC_DIR/exim4/mailbox-quota}}} \
                      {0} \
                    } \
                  } \
                } \
              } \
            } \
          }{\N\b(\d+)([kMG]i?)?\b\N}{\
            ${eval:$1*${extract{\
             ${if eq{$2}{}{b}{$2}}\
            }{k=1000 M=1000000 G=1000000000 T=1000000000000 ki=1024 Mi=1048576 Gi=1073741824 Ti=1099511627776}{$value}{1}}}\
          }{0}}

