Database Configuration

Madmail now supports GORM, which enables the use of various databases and automatic migration (Auto Migration).

Important: SQLite is used by default, but for high scalability, PostgreSQL is recommended.

SQLite (Default)

The simplest setup for quick deployment. The database file is stored at the specified path.

storage.imapsql local_mail {
    driver sqlite3
    dsn ./madmail.db
}

PostgreSQL

To use PostgreSQL, first create a database on your server (you can use the docker-compose.yml included in the project).

Example configuration in maddy.conf:

storage.imapsql local_mail {
    driver postgres
    dsn "host=localhost user=test password=test dbname=test port=5432 sslmode=disable"
}

Default credentials in Docker:

MySQL

To use MySQL, the DSN format is as follows:

storage.imapsql local_mail {
    driver mysql
    dsn "user:password@tcp(localhost:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
}

Migration

The service automatically creates or updates required tables on first run. There is no need to run manual SQL commands to create quotas or contacts tables.