Documentation ¶
Index ¶
- Constants
- Variables
- func HashMailboxName(mailbox string) string
- func JoinStringList(listOfStrings *list.List) string
- func ParseEmailAddress(address string) (local string, domain string, err error)
- func ParseMailboxName(localPart string) (result string, err error)
- func StartRetentionScanner(ds DataStore)
- func ValidateDomainPart(domain string) bool
- type DataStore
- type FileDataStore
- type FileMailbox
- type FileMessage
- func (m *FileMessage) Append(data []byte) error
- func (m *FileMessage) Close() error
- func (m *FileMessage) Date() time.Time
- func (m *FileMessage) Delete() error
- func (m *FileMessage) From() string
- func (m *FileMessage) Id() string
- func (m *FileMessage) RawReader() (reader io.ReadCloser, err error)
- func (m *FileMessage) ReadBody() (body *enmime.MIMEBody, err error)
- func (m *FileMessage) ReadHeader() (msg *mail.Message, err error)
- func (m *FileMessage) ReadRaw() (raw *string, err error)
- func (m *FileMessage) Size() int64
- func (m *FileMessage) String() string
- func (m *FileMessage) Subject() string
- type Mailbox
- type Message
- type Server
- type Session
- type State
Constants ¶
const INDEX_FILE = "index.gob"
Name of index file in each mailbox
const STAMP_FMT = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)"
Variables ¶
var ErrNotExist = errors.New("Message does not exist")
var ErrNotWritable = errors.New("Message not writable")
Functions ¶
func HashMailboxName ¶
Take a mailbox name and hash it into the directory we'll store it in
func JoinStringList ¶
JoinStringList joins a List containing strings by commas
func ParseEmailAddress ¶
ParseEmailAddress unescapes an email address, and splits the local part from the domain part. An error is returned if the local or domain parts fail validation following the guidelines in RFC3696.
func ParseMailboxName ¶
Take "user+ext" and return "user", aka the mailbox we'll store it in Return error if it contains invalid characters, we don't accept anything that must be quoted according to RFC3696.
func StartRetentionScanner ¶
func StartRetentionScanner(ds DataStore)
func ValidateDomainPart ¶
ValidateDomainPart returns true if the domain part complies to RFC3696, RFC1035
Types ¶
type DataStore ¶
type DataStore interface { MailboxFor(emailAddress string) (Mailbox, error) AllMailboxes() ([]Mailbox, error) }
func DefaultFileDataStore ¶
func DefaultFileDataStore() DataStore
DefaultFileDataStore creates a new DataStore object. It uses the inbucket.Config object to construct it's path.
func NewFileDataStore ¶
func NewFileDataStore(cfg config.DataStoreConfig) DataStore
NewFileDataStore creates a new DataStore object using the specified path
type FileDataStore ¶
type FileDataStore struct {
// contains filtered or unexported fields
}
A DataStore is the root of the mail storage hiearchy. It provides access to Mailbox objects
func (*FileDataStore) AllMailboxes ¶
func (ds *FileDataStore) AllMailboxes() ([]Mailbox, error)
AllMailboxes returns a slice with all Mailboxes
func (*FileDataStore) MailboxFor ¶
func (ds *FileDataStore) MailboxFor(emailAddress string) (Mailbox, error)
Retrieves the Mailbox object for a specified email address, if the mailbox does not exist, it will attempt to create it.
type FileMailbox ¶
type FileMailbox struct {
// contains filtered or unexported fields
}
A Mailbox manages the mail for a specific user and correlates to a particular directory on disk.
func (*FileMailbox) GetMessage ¶
func (mb *FileMailbox) GetMessage(id string) (Message, error)
GetMessage decodes a single message by Id and returns a Message object
func (*FileMailbox) GetMessages ¶
func (mb *FileMailbox) GetMessages() ([]Message, error)
GetMessages scans the mailbox directory for .gob files and decodes them into a slice of Message objects.
func (*FileMailbox) NewMessage ¶
func (mb *FileMailbox) NewMessage() (Message, error)
NewMessage creates a new Message object and sets the Date and Id fields. It will also delete messages over messageCap if configured.
func (*FileMailbox) Purge ¶
func (mb *FileMailbox) Purge() error
Delete all messages in this mailbox
func (*FileMailbox) String ¶
func (mb *FileMailbox) String() string
type FileMessage ¶
type FileMessage struct { // Stored in GOB Fid string Fdate time.Time Ffrom string Fsubject string Fsize int64 // contains filtered or unexported fields }
Message contains a little bit of data about a particular email message, and methods to retrieve the rest of it from disk.
func (*FileMessage) Append ¶
func (m *FileMessage) Append(data []byte) error
Append data to a newly opened Message, this will fail on a pre-existing Message and after Close() is called.
func (*FileMessage) Close ¶
func (m *FileMessage) Close() error
Close this Message for writing - no more data may be Appended. Close() will also trigger the creation of the .gob file.
func (*FileMessage) Date ¶
func (m *FileMessage) Date() time.Time
func (*FileMessage) Delete ¶
func (m *FileMessage) Delete() error
Delete this Message from disk by removing both the gob and raw files
func (*FileMessage) From ¶
func (m *FileMessage) From() string
func (*FileMessage) Id ¶
func (m *FileMessage) Id() string
func (*FileMessage) RawReader ¶
func (m *FileMessage) RawReader() (reader io.ReadCloser, err error)
RawReader opens the .raw portion of a Message as an io.ReadCloser
func (*FileMessage) ReadBody ¶
func (m *FileMessage) ReadBody() (body *enmime.MIMEBody, err error)
ReadBody opens the .raw portion of a Message and returns a MIMEBody object
func (*FileMessage) ReadHeader ¶
func (m *FileMessage) ReadHeader() (msg *mail.Message, err error)
ReadHeader opens the .raw portion of a Message and returns a standard Go mail.Message object
func (*FileMessage) ReadRaw ¶
func (m *FileMessage) ReadRaw() (raw *string, err error)
ReadRaw opens the .raw portion of a Message and returns it as a string
func (*FileMessage) Size ¶
func (m *FileMessage) Size() int64
func (*FileMessage) String ¶
func (m *FileMessage) String() string
func (*FileMessage) Subject ¶
func (m *FileMessage) Subject() string
type Message ¶
type Message interface { Id() string From() string Date() time.Time Subject() string RawReader() (reader io.ReadCloser, err error) ReadHeader() (msg *mail.Message, err error) ReadBody() (body *enmime.MIMEBody, err error) ReadRaw() (raw *string, err error) Append(data []byte) error Close() error Delete() error String() string Size() int64 }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Real server code starts here
func NewSmtpServer ¶
func NewSmtpServer(cfg config.SmtpConfig, ds DataStore, db *db.Database) *Server
Init a new Server object