imapsrv

package module
Version: v0.0.0-...-5d24ac4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2014 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Imapsrv

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

Demo

In the demo subdirectory is an example IMAP server that starts up on port 1193. To run this server:

$ go run ./demo/main.go

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

$ nc -C localhost 1193
* OK IMAP4rev1 Service Ready
* LOGIN test anypassword
* OK LOGIN completed
* CAPABILITY
* CAPABILITY IMAP4rev1
* OK CAPABILITY completed
* 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
* OK SELECT completed
* LOGOUT
* BYE IMAP4rev1 Server logging out
* 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.

License

3-clause BSD

Documentation

Overview

An IMAP server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(Addr string) func(*Server) error

Add an interface to listen to

func MaxClients

func MaxClients(max uint) func(*Server) error

Set MaxClients config

func Store

func Store(m Mailstore) func(*Server) error

Add a mailstore to the config

Types

type Config

type Config struct {
	MaxClients uint
	Listeners  []Listener
	Mailstore  Mailstore
}

IMAP server configuration

func DefaultConfig

func DefaultConfig() *Config

Return the default server configuration

type DummyMailstore

type DummyMailstore struct {
}

A dummy mailstore used for demonstrating the IMAP server

func (*DummyMailstore) FirstUnseen

func (m *DummyMailstore) FirstUnseen(mbox int64) (int64, error)

Get the sequence number of the first unseen message

func (*DummyMailstore) GetMailbox

func (m *DummyMailstore) GetMailbox(name string) (*Mailbox, error)

Get mailbox information

func (*DummyMailstore) NextUid

func (m *DummyMailstore) NextUid(mbox int64) (int64, error)

Get the next available uid in an IMAP mailbox

func (*DummyMailstore) RecentMessages

func (m *DummyMailstore) RecentMessages(mbox int64) (int64, error)

Get the total number of unread messages in an IMAP mailbox

func (*DummyMailstore) TotalMessages

func (m *DummyMailstore) TotalMessages(mbox int64) (int64, error)

Get the total number of messages in an IMAP mailbox

type Listener

type Listener struct {
	Addr string
}

A listener is listening on a given address. Ex: 0.0.0.0:193

type Mailbox

type Mailbox struct {
	Name string // The name of the mailbox
	Id   int64  // The id of the mailbox
}

An IMAP mailbox

type Mailstore

type Mailstore interface {
	// Get IMAP mailbox information
	// Returns nil if the mailbox does not exist
	GetMailbox(name string) (*Mailbox, error)
	// Get the sequence number of the first unseen message
	FirstUnseen(mbox int64) (int64, error)
	// Get the total number of messages in an IMAP mailbox
	TotalMessages(mbox int64) (int64, error)
	// Get the total number of unread messages in an IMAP mailbox
	RecentMessages(mbox int64) (int64, error)
	// Get the next available uid in an IMAP mailbox
	NextUid(mbox int64) (int64, error)
}

A service that is needed to read mail messages

type Server

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

An IMAP Server

func Create

func Create(config *Config) *Server

Create an IMAP server

func NewServer

func NewServer(options ...func(*Server) error) *Server

func (*Server) Start

func (s *Server) Start() error

Start an IMAP server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL