# Configuration for the mailteam policy daemon

user=mtpolicyd
group=mtpolicyd

# 0=>'err', 1=>'warning', 2=>'notice', 3=>'info', 4=>'debug' (default: 2)
log_level=2

host=10.10.10.10
port="10.10.10.10:12345"

min_servers=4
min_spare_servers=4
max_spare_servers=12
max_servers=50
max_requests=1000

#keepalive_timeout=60
keepalive_timeout=0
# should be the same value as smtpd_policy_service_reuse_count_limit (postfix >2.12)
max_keepalive=0
#max_keepalive=100

# timeout for processing of one request in seconds
request_timeout=20

vhost_by_policy_context=1

<Connection memcached>
  module = "Memcached"
  servers = "127.0.0.1:11211"
  # namespace = "mt-"
</Connection>

# mysql for storing accounting tables
<Connection db>
  module = "Sql"
  # see perldoc DBI for syntax of dsn connection string
  dsn = "dbi:mysql:database=mailpolicy;host=localhost;port=3306"
  user = "mtpolicyd"
  password = "mysqlpassword"
</Connection>

# ldap with user configuration
<Connection ldap>
  module = "Ldap"
  host = "ldap.example.com"
  port = 389
  timeout = 20
  binddn = "uid=mtpolicyd,o=admins,c=en"
  password = "ldappassword"
  starttls = 0
</Connection>



<SessionCache>
  module = "Memcached"
  #memcached = "memcached"
  # expire session cache entries
  expire = "300"
  # wait timeout will be increased each time 50,100,150,... (usec)
  lock_wait=50
  # abort after n retries
  lock_max_retry=50
  # session lock times out after (sec)
  lock_timeout=10
</SessionCache>



<VirtualHost 12345>
  name="accounting"

  <Plugin LdapUID>
    module="LdapUserConfig"
    basedn="c=en"
    # sasl_username attribute is uid.
    filter_field="sasl_username"
    filter="(&(uid=%s)(objectClass=mailRecipient)(objectclass=mtpolicyd)(mailUserStatus=active))"
    # copy these fields to current mtpolicyd session
    config_fields="mtpolicydMailMessageLimit,mtpolicydMailRecipientLimit"
  </Plugin>

  <Plugin QuotaUser>
    module = "Quota"
    time_pattern = "%Y-%m-%d"
    field = "sasl_username"
    metric = "count"
    threshold = 500
    # if this field is set it will overwrite the default threshold
    uc_threshold = "mtpolicydMailMessageLimit"
    # for MSA you may reject, for MTAs you may defer
    action = "reject you exceeded your daily message limit"
  </Plugin>

  <Plugin QuotaUserRecipient>
    module = "Quota"
    time_pattern = "%Y-%m-%d"
    field = "sasl_username"
    metric = "count_rcpt"
    threshold = 5000
    # if this field is set it will overwrite the default threshold
    uc_threshold = "mtpolicydMailRecipientLimit"
    # for MSA you may reject, for MTAs you may defer
    action = "reject you exceeded your daily mail recipient limit"
  </Plugin>

  <Plugin AcctUser>
    module = "Accounting"
    fields = "sasl_username"
    # Perform day based limit
    time_pattern = "%Y-%m-%d"
  </Plugin>

</VirtualHost>