mail_plugins {
  quota = yes
  quota_clone = yes
  sieve = yes
  imapsieve = yes
}

quota "User quota" {
  driver = count
}

dict_server {
  dict mysqlquota {
    driver = sql
    sql_driver = mysql

    mysql __DB_HOST__ {
      port = __DB_PORT__
      dbname = __DB_NAME__
      user = __DB_USER__
      password = __DB_PASS__
    }

    dict_map priv/quota/messages {
      sql_table = accounts
      username_field = username
      value_field quota_messages {
      }
    }

    dict_map priv/quota/storage {
      sql_table = accounts
      username_field = username
      value_field quota_bytes {
      }
    }
  }
}

quota_clone {
  dict proxy {
    name = mysqlquota
  }
}
