maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

  1# SQL-indexed storage
  2
  3The imapsql module implements database for IMAP index and message
  4metadata using SQL-based relational database.
  5
  6Message contents are stored in an "blob store" defined by msg_store
  7directive. By default this is a file system directory under /var/lib/maddy.
  8
  9Supported RDBMS:
 10- SQLite 3.25.0
 11- PostgreSQL 9.6 or newer
 12- CockroachDB 20.1.5 or newer
 13
 14Account names are required to have the form of a email address (unless configured otherwise)
 15and are case-insensitive. UTF-8 names are supported with restrictions defined in the
 16PRECIS UsernameCaseMapped profile.
 17
 18```
 19storage.imapsql {
 20	driver sqlite3
 21	dsn imapsql.db
 22	msg_store fs messages/
 23}
 24```
 25
 26imapsql module also can be used as a lookup table.
 27It returns empty string values for existing usernames. This might be useful
 28with `destination_in` directive e.g. to implement catch-all
 29addresses (this is a bad idea to do so, this is just an example):
 30```
 31destination_in &local_mailboxes {
 32	deliver_to &local_mailboxes
 33}
 34destination example.org {
 35	modify {
 36		replace_rcpt regexp ".*" "catchall@example.org"
 37	}
 38	deliver_to &local_mailboxes
 39}
 40```
 41
 42
 43## Arguments
 44
 45Specify the driver and DSN.
 46
 47## Configuration directives
 48
 49### driver _string_
 50**Required.**<br>
 51Default: not specified
 52
 53Use a specified driver to communicate with the database. Supported values:
 54sqlite3, postgres.
 55
 56Should be specified either via an argument or via this directive.
 57
 58---
 59
 60### dsn _string_
 61**Required.**<br>
 62Default: not specified
 63
 64Data Source Name, the driver-specific value that specifies the database to use.
 65
 66For SQLite3 this is just a file path.
 67For PostgreSQL: [https://godoc.org/github.com/lib/pq#hdr-Connection\_String\_Parameters](https://godoc.org/github.com/lib/pq#hdr-Connection\_String\_Parameters)
 68
 69Should be specified either via an argument or via this directive.
 70
 71---
 72
 73### msg_store _store_
 74Default: `fs messages/`
 75
 76Module to use for message bodies storage.
 77
 78See "Blob storage" section for what you can use here.
 79
 80---
 81
 82### compression `off`<br>compression _algorithm_<br>compression _algorithm_ _level_
 83Default: `off`
 84
 85Apply compression to message contents.
 86Supported algorithms: `lz4`, `zstd`.
 87
 88---
 89
 90### appendlimit _size_
 91Default: `32M`
 92
 93Don't allow users to add new messages larger than 'size'.
 94
 95This does not affect messages added when using module as a delivery target.
 96Use `max_message_size` directive in SMTP endpoint module to restrict it too.
 97
 98---
 99
100### debug _boolean_
101Default: global directive value
102
103Enable verbose logging.
104
105---
106
107### junk_mailbox _name_
108Default: `Junk`
109
110The folder to put quarantined messages in. Thishis setting is not used if user
111does have a folder with "Junk" special-use attribute.
112
113---
114
115### disable_recent _boolean_
116Default: `true`
117
118Disable RFC 3501-conforming handling of \Recent flag.
119
120This significantly improves storage performance when SQLite3 or CockroackDB is
121used at the cost of confusing clients that use this flag.
122
123---
124
125### sqlite_cache_size _integer_
126Default: defined by SQLite
127
128SQLite page cache size. If positive - specifies amount of pages (1 page - 4
129KiB) to keep in cache. If negative - specifies approximate upper bound
130of cache size in KiB.
131
132---
133
134### sqlite_busy_timeout _integer_
135Default: `5000000`
136
137SQLite-specific performance tuning option. Amount of milliseconds to wait
138before giving up on DB lock.
139
140---
141
142### imap_filter { ... }
143Default: not set
144
145Specifies IMAP filters to apply for messages delivered from SMTP pipeline.
146
147Ex.
148
149```
150imap_filter {
151	command /etc/maddy/sieve.sh {account_name}
152}
153```
154
155---
156
157### delivery_map _table_
158Default: `identity`
159
160Use specified table module to map recipient
161addresses from incoming messages to mailbox names.
162
163Normalization algorithm specified in `delivery_normalize` is appied before
164`delivery_map`.
165
166---
167
168### delivery_normalize _name_
169Default: `precis_casefold_email`
170
171Normalization function to apply to email addresses before mapping them
172to mailboxes.
173
174See `auth_normalize`.
175
176---
177
178### auth_map _table_
179**Deprecated:** Use `storage_map` in imap config instead.<br>
180Default: `identity`
181
182Use specified table module to map authentication
183usernames to mailbox names.
184
185Normalization algorithm specified in auth_normalize is applied before
186auth_map.
187
188---
189
190### auth_normalize _name_
191**Deprecated:** Use `storage_map_normalize` in imap config instead.<br>
192**Default**: `precis_casefold_email`
193
194Normalization function to apply to authentication usernames before mapping
195them to mailboxes.
196
197Available options:
198
199- `precis_casefold_email`   PRECIS UsernameCaseMapped profile + U-labels form for domain
200- `precis_casefold`         PRECIS UsernameCaseMapped profile for the entire string
201- `precis_email`            PRECIS UsernameCasePreserved profile + U-labels form for domain
202- `precis`                  PRECIS UsernameCasePreserved profile for the entire string
203- `casefold`                Convert to lower case
204- `noop`                    Nothing
205
206Note: On message delivery, recipient address is unconditionally normalized
207using `precis_casefold_email` function.
208