pinbox

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

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

Go to latest
Published: Dec 13, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

README

Pinbox webmail backend

Pinbox is a self-hosted webmail client greatly inspired by Google Inbox.

Warning: Currently under development

Prerequsites

Configuration

Pinbox server requires a TOML configuration file to define the Maildir location, port etc. See example/config.toml.

Starting the server

make && ./pinbox-server config.toml`

Architecture

Client App -> Backend API -> Notmuch -> OfflineIMAP

License

Licensed under GPL-3.0-or-later

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inbox

func Inbox(mailbox Mailbox, config Config) ([]interface{}, error)

Inbox returns all email messages that match the configured 'Inbox' whilst grouping together any messages that match the labels configured in the 'Bundle' list.

Returns a mixed list of Thread and Bundle objects. The list is returned in reverse chronological order.

Types

type Bundle

type Bundle struct {
	ID      string   `json:"id"`
	Type    string   `json:"type"`
	Date    int64    `json:"date"`
	Threads []Thread `json:"threads"`
}

A Bundle represents a group of Threads.

type Config

type Config struct {
	Maildir         string
	TLS             bool
	CertificateFile string `toml:"certificate_file"`
	CertificateKey  string `toml:"certificate_key"`
	Port            int
	Inbox           string
	Bundle          []string
	Hidden          []string
}

Config holds any settings used to define the behaviour of the service. For example to set the port to host the API on etc.

func ReadConfigFile

func ReadConfigFile(path string) (Config, error)

ReadConfigFile loads the configuration file from disk. Returns a Config object.

type Label

type Label struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

A Label is a tag that can be used to organise messages in the Mailbox.

type Mailbox

type Mailbox interface {
	Labels() ([]Label, error)
	ReadMessage(id string) (MessageContent, error)
	Search(query string) ([]Thread, error)
}

The Mailbox interface acts as a wrapper for all email actions to abstract any direct email access from the business logic of the Pinbox API transport.

type MailboxAPI

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

MailboxAPI contains logic for handling mailbox http requests

func CreateMailboxAPI

func CreateMailboxAPI(mailbox Mailbox, config Config) *MailboxAPI

CreateMailboxAPI creates a new Mailbox API instance. Return a new MailboxAPI reference.

func (*MailboxAPI) GetInbox

func (m *MailboxAPI) GetInbox(writer http.ResponseWriter, req *http.Request)

GetInbox retrieves all inbox messages in the Mailbox.

func (*MailboxAPI) GetLabels

func (m *MailboxAPI) GetLabels(writer http.ResponseWriter, req *http.Request)

GetLabels retrieves the available labels in the Mailbox.

func (*MailboxAPI) HandleAllMessages

func (m *MailboxAPI) HandleAllMessages(writer http.ResponseWriter, req *http.Request)

HandleAllMessages retrieves all messages in the Mailbox.

func (*MailboxAPI) HandleLabeledMessages

func (m *MailboxAPI) HandleLabeledMessages(writer http.ResponseWriter, req *http.Request)

HandleLabeledMessages retrieves any messages in the Mailbox with the specified labels.

func (*MailboxAPI) HandleSingleMessage

func (m *MailboxAPI) HandleSingleMessage(writer http.ResponseWriter, req *http.Request)

HandleSingleMessage retrieves a message by ID from the Mailbox.

type Message

type Message struct {
	ID     string   `json:"id"`
	Epoch  int64    `json:"epoch"`
	Author string   `json:"author"`
	Files  []string `json:"files"`
}

A Message represents an individual email.

type MessageContent

type MessageContent struct {
	ID      string `json:"id"`
	Epoch   int64  `json:"epoch"`
	Author  string `json:"author"`
	Content string `json:"content"`
}

MessageContent is a container for the body of a Message.

type Notmuch

type Notmuch struct {
	DbPath        string
	ExcludeLabels []string
	InboxLabel    string
	Bundle        []string
}

Notmuch is a Mailbox object intended to interact with a Notmuch database. See https://notmuchmail.org/ for more information.

func CreateNotmuch

func CreateNotmuch(config Config) *Notmuch

CreateNotmuch creates a new Notmuch object ready to interact with the database specified by the given configuration.

func (*Notmuch) Labels

func (mailbox *Notmuch) Labels() ([]Label, error)

Labels returns a list of Label objects corresponding to 'tags' configured in the Notmuch database. Any label IDs specified in Notmuch.ExcludeLabels will be omitted.

func (*Notmuch) ReadMessage

func (mailbox *Notmuch) ReadMessage(id string) (MessageContent, error)

ReadMessage retrieves the content of an email. Returns a MessageContent object containing email body encoded in base64.

func (*Notmuch) Search

func (mailbox *Notmuch) Search(query string) ([]Thread, error)

Search retrieves emails from the Notmuch database based on a given query. The query string must be provided in Xapian query format (https://notmuchmail.org/searching/).

type Thread

type Thread struct {
	ID         string    `json:"id"`
	Type       string    `json:"type"`
	Subject    string    `json:"subject"`
	NewestDate int64     `json:"newestDate"`
	OldestDate int64     `json:"oldestDate"`
	Authors    []string  `json:"authors"`
	Messages   []Message `json:"messages"`
}

A Thread represents a Message chain stored in the Mailbox.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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