SQL-based storage backend for go-imap library.
Go 1.13 is required due to use of Go 1.13 error inspection features.
go-imap-sql is known to work with (and constantly being tested against) following RDBMS:
- SQLite 3.25.0
- PostgreSQL 9.6
Following RDBMS was actively supported in the past, it's unknown whether they still work with go-imap-sql:
- MariaDB 10.2
Usernames are always converted to lower-case before doing anything.
This means that if you type imapsql-ctl ... users create FOXCPP
. Account
with username foxcpp
will be created. Also this means that you can use any
case in account settings in your IMAP client.
go-imap-sql uses bcrypt hash function for account passwords. This makes passwords hard to brute-force, but also significantly increases CPU load.
Backend users should either change hash function to sha3-512 (see Opts structure documentation) or implement restrictions on authentication attempts that will block access after certain number of attempts.
You may want to overwrite deleted messages and theirs meta-data with zeroes for security/privacy reasons. For MySQL, PostgreSQL - consult documentation (AFAIK, there is no such option).
For SQLite3, you should build go-imap-sql with sqlite_secure_delete
build tag.
It will enable corresponding SQLite3 feature by default for all databases.
If you want to enable it per-database - you can use
file:PATH?_secure_delete=ON
in DSN.
go-imap-sql never invalidates UIDs in an existing mailbox. If mailbox is DELETE'd then UIDVALIDITY value changes.
Unlike many popular IMAP server implementations, go-imap-sql uses randomly generated UIDVALIDITY values instead of timestamps.
This makes several things easier to implement with less edge cases. And answer to the question you are already probably asked: To make go-imap-sql malfunction you need to get Go's PRNG to generate two equal integers in range of [1, 2^32-1] just at right moment (seems unlikely enough to ignore it). Even then, it will not cause much problems due to the way most client implementations work.
go-imap-sql uses separate math/rand.Rand
instance and seeds it with system
time on initialization (in New
).
You can provide custom pre-seeded struct implementing math/rand.Source
in Opts
struct (PRNG
field).
You can use go-imap-sql as part of the maddy mail server.
For direct access to database you can use imapsql-ctl console utility. See more information in separate README here.
go install github.com/foxcpp/go-imap-sql/cmd/imapsql-ctl