imapsrv

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

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

Go to latest
Published: Jun 28, 2015 License: BSD-3-Clause Imports: 10 Imported by: 5

README

Stories in Ready

Imapsrv

This is an IMAP server written in Go. It is a work in progress.

Demo

In the demo subdirectory there are several implementation examples available.

$ go run ./demo/basic/main.go

You can connect to this server using telnet or netcat. For example:

$ nc -C localhost 1193
* OK IMAP4rev1 Service Ready
10 LOGIN test anypassword
10 OK LOGIN completed
20 CAPABILITY
* CAPABILITY IMAP4rev1
20 OK CAPABILITY completed
30 SELECT inbox
* 8 EXISTS
* 4 RECENT
* OK [UNSEEN 4] Message 4 is first unseen
* OK [UIDVALIDITY 1] UIDs valid
* OK [UIDNEXT 9] Predicted next UID
30 OK SELECT completed
40 LOGOUT
* BYE IMAP4rev1 Server logging out
40 OK LOGOUT completed

Developing

The server is not fully operational on its own. It requires a mailstore and an authentication mechanism.

It defines an interface in mailstore.go which describes the service it needs from a Mailstore. For example a Mailstore could serve its data from: database, filesystem, maildir, etc... At the moment only one mailstore can be used at the same time.

To add a new IMAP command the usual steps are:

  1. Add the command to parser.go
  2. Add the command and its client interaction to commands.go
  3. Put the main functionality in session.go.

Current state

IMAP (RFC 3501)
Client Commands - Any state
  • CAPABILITY command - in progress
  • NOOP command
  • LOGOUT command
Client Commands - Not-Authenticated State
  • STARTTLS command
  • AUTHENTICATE command
  • LOGIN command
Client Commands - Authenticated State
  • SELECT command
  • EXAMINE command
  • CREATE command
  • DELETE command
  • RENAME command
  • SUBSCRIBE command
  • UNSUBSCRIBE command
  • LIST command
  • LSUB command
  • STATUS command
  • APPEND command
Client Commands - Selected State
  • CHECK command
  • CLOSE command
  • EXPUNGE command
  • SEARCH command
  • FETCH command - in progress
  • STORE command
  • COPY command
  • UID command
Server responses
  • OK response
  • NO response
  • BAD response
  • PREAUTH response
  • BYE response

License

3-clause BSD

Documentation

Overview

An IMAP server

Index

Constants

View Source
const (
	// Noinferiors indicates it is not possible for any child levels of hierarchy to exist
	// under this name; no child levels exist now and none can be
	// created in the future.
	Noinferiors = 1 << iota

	// Noselect indicates it is not possible to use this name as a selectable mailbox.
	Noselect

	// Marked indicates that the mailbox has been marked "interesting" by the server;
	// the mailbox probably contains messages that have been added since
	// the last time the mailbox was selected
	Marked

	// Unmarked indicates the mailbox does not contain any additional messages since the
	// last time the mailbox was selected.
	Unmarked
)

Mailbox flags

View Source
const DefaultListener = "0.0.0.0:143"

DefaultListener is the listener that is used if no listener is specified

Variables

This section is empty.

Functions

func AuthStoreOption

func AuthStoreOption(a auth.AuthStore) option

AuthStoreOption adds an authenticaton backend

func ListenOption

func ListenOption(Addr string) option

ListenOption adds an interface to listen to

func ListenSTARTTLSOoption

func ListenSTARTTLSOoption(Addr, certFile, keyFile string) option

ListenSTARTTLSOoption enables STARTTLS with the given certificate and keyfile

func MaxClientsOption

func MaxClientsOption(max uint) option

MaxClientsOption sets the MaxClients config

func StoreOption

func StoreOption(m Mailstore) option

Add a mailstore to the config StoreOption add a mailstore to the config

Types

type Mailbox

type Mailbox struct {
	Name  string   // The name of the mailbox
	Path  []string // Full mailbox path
	Id    int64    // The id of the mailbox
	Flags uint8    // Mailbox flags
}

Mailbox represents an IMAP mailbox

type Mailstore

type Mailstore interface {
	// GetMailbox gets IMAP mailbox information
	// Returns nil if the mailbox does not exist
	GetMailbox(path []string) (*Mailbox, error)
	// GetMailboxes gets a list of mailboxes at the given path
	GetMailboxes(path []string) ([]*Mailbox, error)
	// FirstUnseen gets the sequence number of the first unseen message in an IMAP mailbox
	FirstUnseen(mbox int64) (int64, error)
	// TotalMessages gets the total number of messages in an IMAP mailbox
	TotalMessages(mbox int64) (int64, error)
	// RecentMessages gets the total number of unread messages in an IMAP mailbox
	RecentMessages(mbox int64) (int64, error)
	// NextUid gets the next available uid in an IMAP mailbox
	NextUid(mbox int64) (int64, error)
}

Mailstore is a service responsible for I/O with the actual e-mails

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an IMAP Server

func NewServer

func NewServer(options ...option) *Server

NewServer creates a new server with the given options

func (*Server) Start

func (s *Server) Start() error

Start an IMAP server

Directories

Path Synopsis
boltstore
Package boltstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using github.com/boltdb/bolt - DB.
Package boltstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using github.com/boltdb/bolt - DB.
mysqlstore
Package mysqlstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using MySQL
Package mysqlstore holds an implementation of github.com/alienscience/imapsrv/auth - AuthStore, using MySQL
demo

Jump to

Keyboard shortcuts

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