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:
- Username:
test
- Password:
test
- Database:
test
MySQL
To use MySQL, the DSN format is as follows:
storage.imapsql local_mail {
dsn "user:password@tcp(localhost:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
}
In-memory caches vs on-disk state
For performance, the running server may keep a copy of credential rows (auth.pass_table) and per-user quota totals (storage.imapsql) in RAM. The authoritative data remains in the database files.
If you change those databases with the CLI (for example maddy creds, maddy accounts, or maddy imap-acct) while the daemon stays up, call the Admin API resource POST /admin/cache/reload once so the process re-reads the tables. Alternatively, restart the service.
Migration
The service automatically creates or updates required tables on first run. There is no need to run manual SQL
commands to create the quotas or contacts tables.
Ù¾ÛÚ©Ø±Ø¨ÙØ¯Û پاÛگا٠داد٠(Database Configuration)
سرÙÛØ³ Madmail اکÙÙ٠از GORM Ù¾Ø´ØªÛØ¨Ø§ÙÛ Ù
ÛâÚ©ÙØ¯ Ú©Ù
اÙ
Ú©Ø§Ù Ø§Ø³ØªÙØ§Ø¯Ù از پاÛگا٠دادÙâÙØ§Û Ù
ختÙÙ Ù Ù
ÙØ§Ø¬Ø±Øª Ø®ÙØ¯Ú©Ø§Ø± (Auto Migration) را ÙØ±Ø§ÙÙ
Ù
ÛâØ³Ø§Ø²Ø¯.
Ùکت٠Ù
ÙÙ
: Ø¨Ù Ø·ÙØ± Ù¾ÛØ´âÙØ±Ø¶ از SQLite Ø§Ø³ØªÙØ§Ø¯Ù Ù
ÛâØ´ÙØ¯Ø اÙ
ا Ø¨Ø±Ø§Û Ù
ÙÛØ§Ø³âÙ¾Ø°ÛØ±Û Ø¨Ø§ÙØ§Ø Ø§Ø³ØªÙØ§Ø¯Ù از
PostgreSQL ØªÙØµÛÙ Ù
Ûâگردد.
SQLite (Ù¾ÛØ´âÙØ±Ø¶)
سادÙâØªØ±ÛÙ ØØ§Ùت Ø¨Ø±Ø§Û Ø±Ø§ÙâØ§ÙØ¯Ø§Ø²Û Ø³Ø±ÛØ¹. ÙØ§Û٠پاÛگا٠داد٠در Ù
Ø³ÛØ± Ù
شخص Ø´Ø¯Ù Ø°Ø®ÛØ±Ù Ù
ÛâØ´ÙØ¯.
storage.imapsql local_mail {
driver sqlite3
dsn ./madmail.db
}
PostgreSQL
Ø¨Ø±Ø§Û Ø§Ø³ØªÙØ§Ø¯Ù از PostgreSQLØ Ø§Ø¨ØªØ¯Ø§ ÛÚ© Ø¯ÛØªØ§Ø¨Ûس در Ø³Ø±ÙØ± Ø®ÙØ¯ Ø§ÛØ¬Ø§Ø¯ Ú©ÙÛØ¯ (Ù
ÛâØªÙØ§ÙÛØ¯ از
docker-compose.yml Ù
ÙØ¬Ùد در پرÙÚÙ Ø§Ø³ØªÙØ§Ø¯Ù Ú©ÙÛØ¯).
ÙÙ
ÙÙÙ ØªÙØ¸ÛÙ
ات در ÙØ§ÛÙ maddy.conf:
storage.imapsql local_mail {
driver postgres
dsn "host=localhost user=test password=test dbname=test port=5432 sslmode=disable"
}
Ø§Ø·ÙØ§Ø¹Ø§Øª Ù¾ÛØ´âÙØ±Ø¶ در Docker:
- ÙØ§Ù
کاربرÛ:
test
- رÙ
ز Ø¹Ø¨ÙØ±:
test
- ÙØ§Ù
Ø¯ÛØªØ§Ø¨Ûس:
test
MySQL
Ø¨Ø±Ø§Û Ø§Ø³ØªÙØ§Ø¯Ù از MySQLØ ÙØ±Ù
ت DSN Ø¨Ù ØµÙØ±Øª Ø²ÛØ± است:
storage.imapsql local_mail {
dsn "user:password@tcp(localhost:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
}
Ú©Ø´ ØØ§Ùظ٠در برابر Ø¯ÛØªØ§Ø¨Ûس رÙÛ Ø¯ÛØ³Ú©
Ø¨Ø±Ø§Û Ø³Ø±Ø¹ØªØ Ø³Ø±ÙØ± در ØØ§Ù اجرا Ù
Ù
ک٠است ردÛÙâÙØ§Û Ø§Ø¹ØªØ¨Ø§Ø±ÙØ§Ù
Ù (auth.pass_table) Ù Ù
جÙ
ÙØ¹ سÙÙ
ÛÙ ÙØ± کاربر (storage.imapsql) را در RAM Ùگ٠دارد. Ù
ÙØ¨Ø¹ ØÙÛÙÛ ÙÙ
ÚÙØ§Ù ÙØ§ÛÙâÙØ§Û Ø¯ÛØªØ§Ø¨Ûس است.
اگر با CLI (Ù
Ø«ÙØ§Ù maddy credsØ maddy accounts ÛØ§ maddy imap-acct) در ØØ§ÙÛ Ú©Ù Ø³Ø±ÙÛØ³ Ø±ÙØ´Ù است Ø¯ÛØªØ§Ø¨Ûس را Ø¹ÙØ¶ Ú©Ø±Ø¯ÛØ¯Ø ÛÚ© بار Admin API را با POST /admin/cache/reload صدا بزÙÛØ¯ تا ÙØ±Ø¢ÛÙØ¯ Ø¯ÙØ¨Ø§Ø±Ù جداÙ٠را Ø¨Ø®ÙØ§ÙØ¯Ø ÛØ§ سرÙÛØ³ را رÛâØ§Ø³ØªØ§Ø±Øª Ú©ÙÛØ¯.
Ù
ÙØ§Ø¬Ø±Øª (Migration)
سرÙÛØ³ Ø¨Ù ØµÙØ±Øª Ø®ÙØ¯Ú©Ø§Ø± جداÙÙ Ù
ÙØ±Ø¯ ÙÛØ§Ø² را در اÙÙÛ٠اجرا Ø§ÛØ¬Ø§Ø¯ ÛØ§ بÙâØ±ÙØ²Ø±Ø³Ø§ÙÛ Ù
ÛâÚ©ÙØ¯. ÙÛØ§Ø²Û Ø¨Ù Ø§Ø¬Ø±Ø§Û Ø¯Ø³ØªÙØ±Ø§Øª SQL
Ø¯Ø³ØªÛ Ø¨Ø±Ø§Û Ø³Ø§Ø®Øª جداÙÙ quotas ÛØ§ contacts ÙÛØ³Øª.