sqlmail

package module
v0.0.0-...-e2a302b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 3 Imported by: 0

README

go-sqlmail

Travis CI CodeCov Issues License

SQL-based storage backend for go-imap and go-smtp (not yet) libraries.

Building

Go 1.11 is required because we are using modules. Things may work on older versions but these configurations will not be supported.

RDBMS support

go-sqlmail is known to work with (and constantly being tested against) following RDBMS:

  • SQLite 3.25.0
  • MySQL 5.7 (or MariaDB 10.2)
  • PostgreSQL 9.6

Note: MySQL 5.7 support is deprecated since it's addition and not even strictly safe to use. Please stick to using newer versions (MySQL 8 or compatible MariaDB version) when possible.

IMAP Extensions Supported

Due to go-imap architecture, some extensions require support from used backend. Here are extensions supported by go-sqlmail:

UIDVALIDITY

go-sqlmail never invalidates UIDs in an existing mailbox. If mailbox is DELETE'd then UIDVALIDITY value changes.

Unlike many popular IMAP server implementations, go-sqlmail 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-sqlmail 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-sqlmail uses separate math/rand.Rand instance and seeds it with system time on initialization (in NewBackend).

You can provide custom pre-seeded struct implementing math/rand.Source in Opts struct (PRNG field).

Maddy

You can try go-sqlmail as part of maddy mail server. Currently it is not merged into upstream yet so here is where you should get code from: https://github.com/foxcpp/maddy/tree/sqlmail

You need to execute this command prior to building to get lastest development version:

go get github.com/foxcpp/go-sqlmail@dev

Here is minimal example for testing, using SQLite (you need CGo for SQLite!):

imap://127.0.0.1:1993 {
    sql sqlite3 maddy.db
    insecureauth
}
sqlmail-ctl

For direct access to database you can use sqlmail-ctl. See more information in separate README here.

go install github.com/foxcpp/go-sqlmail/cmd/sqlmail-ctl

Documentation

Index

Constants

View Source
const VersionMajor = 0
View Source
const VersionMinor = 1
View Source
const VersionPatch = 0
View Source
const VersionStr = "0.1"
View Source
const VersionSuppl = ""

Variables

View Source
var (
	ErrUserAlreadyExists = errors.New("imap: user already exists")
	ErrUserDoesntExists  = errors.New("imap: user doesn't exists")
)

Functions

This section is empty.

Types

type AppendLimitBackend

type AppendLimitBackend interface {
	appendlimit.Backend

	// SetMessageLimit sets new value for limit.
	// nil pointer means no limit.
	SetMessageLimit(val *uint32) error
}

AppendLimitBackend is extension for main backend interface (backend.Backend) which allows to set append limit value for testing and administration purposes.

type AppendLimitMbox

type AppendLimitMbox interface {
	CreateMessageLimit() *uint32

	// SetMessageLimit sets new value for limit.
	// nil pointer means no limit.
	SetMessageLimit(val *uint32) error
}

AppendLimitMbox is extension for backend.Mailbox interface which allows to set append limit value for testing and administration purposes.

type AppendLimitUser

type AppendLimitUser interface {
	appendlimit.User

	// SetMessageLimit sets new value for limit.
	// nil pointer means no limit.
	SetMessageLimit(val *uint32) error
}

AppendLimitUser is extension for backend.User interface which allows to set append limit value for testing and administration purposes.

type IMAPUsersDB

type IMAPUsersDB interface {
	UsersDB

	// GetUser is same as Backend.Login but doesn't
	// performs any authentication.
	GetUser(username string) (backend.User, error)
}

type UsersDB

type UsersDB interface {
	// CreateUser creates new user with specified username.
	//
	// No mailboxes are created for new user, even INBOX.  This should be done
	// manually using CreateMailbox.
	//
	// It is error to create user which already exists.  ErrUserAlreadyExists
	// will be returned in this case.
	CreateUser(username, password string) error

	// DeleteUser deletes user account from backend storage, along with all
	// mailboxes and messages.
	//
	// It is error to delete user which doesn't exists.  ErrUserDoesntExists
	// will be returned in this case.
	DeleteUser(username string) error

	// SetUserPassword updates password of existsing user.
	//
	// It is error to update user which doesn't exists.  ErrUserDoesntExists
	// will be returned in this case.
	SetUserPassword(username, newPassword string) error
}

UsersDB is additional backend interface that allows external code to perform administrative actions on backend's storage related to users.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL