Documentation ¶
Index ¶
- func HeaderToString(h mail.Header) string
- type DummyMailbox
- func (m *DummyMailbox) DebugPrintMailbox()
- func (m *DummyMailbox) DeleteFlaggedMessages() ([]Message, error)
- func (m *DummyMailbox) LastUID() uint32
- func (m *DummyMailbox) MessageBySequenceNumber(seqno uint32) Message
- func (m *DummyMailbox) MessageByUID(uidno uint32) Message
- func (m *DummyMailbox) MessageSetBySequenceNumber(set types.SequenceSet) []Message
- func (m *DummyMailbox) MessageSetByUID(set types.SequenceSet) []Message
- func (m *DummyMailbox) Messages() uint32
- func (m *DummyMailbox) Name() string
- func (m *DummyMailbox) NewMessage() Message
- func (m *DummyMailbox) NextUID() uint32
- func (m *DummyMailbox) Recent() uint32
- func (m *DummyMailbox) Unseen() uint32
- type DummyMailstore
- type DummyMessage
- func (m *DummyMessage) AddFlags(newFlags types.Flags) Message
- func (m *DummyMessage) Body() string
- func (m *DummyMessage) Flags() types.Flags
- func (m *DummyMessage) Header() (hdr mail.Header)
- func (m *DummyMessage) InternalDate() time.Time
- func (m *DummyMessage) Keywords() []string
- func (m *DummyMessage) OverwriteFlags(newFlags types.Flags) Message
- func (m *DummyMessage) RemoveFlags(newFlags types.Flags) Message
- func (m *DummyMessage) Save() (Message, error)
- func (m *DummyMessage) SequenceNumber() uint32
- func (m *DummyMessage) SetBody(newBody string) Message
- func (m *DummyMessage) SetHeaders(newHeader mail.Header) Message
- func (m *DummyMessage) Size() uint32
- func (m *DummyMessage) UID() uint32
- type DummyUser
- type FilesystemMailbox
- func (m *FilesystemMailbox) DebugPrintMailbox()
- func (m *FilesystemMailbox) DeleteFlaggedMessages() ([]Message, error)
- func (m *FilesystemMailbox) LastUID() uint32
- func (m *FilesystemMailbox) MessageBySequenceNumber(seqno uint32) Message
- func (m *FilesystemMailbox) MessageByUID(uidno uint32) Message
- func (m *FilesystemMailbox) MessageSetBySequenceNumber(set types.SequenceSet) []Message
- func (m *FilesystemMailbox) MessageSetByUID(set types.SequenceSet) []Message
- func (m *FilesystemMailbox) Messages() uint32
- func (m *FilesystemMailbox) Name() string
- func (m *FilesystemMailbox) NewMessage() Message
- func (m *FilesystemMailbox) NextUID() uint32
- func (m *FilesystemMailbox) Recent() uint32
- func (m *FilesystemMailbox) Unseen() uint32
- type FilesystemMailstore
- type FilesystemMessage
- func (m *FilesystemMessage) AddFlags(newFlags types.Flags) Message
- func (m *FilesystemMessage) Body() string
- func (m *FilesystemMessage) Flags() types.Flags
- func (m *FilesystemMessage) Header() (hdr mail.Header)
- func (m *FilesystemMessage) InternalDate() time.Time
- func (m *FilesystemMessage) Keywords() []string
- func (m *FilesystemMessage) OverwriteFlags(newFlags types.Flags) Message
- func (m *FilesystemMessage) RemoveFlags(newFlags types.Flags) Message
- func (m *FilesystemMessage) Save() (Message, error)
- func (m *FilesystemMessage) SequenceNumber() uint32
- func (m *FilesystemMessage) SetBody(newBody string) Message
- func (m *FilesystemMessage) SetHeaders(newHeader mail.Header) Message
- func (m *FilesystemMessage) Size() uint32
- func (m *FilesystemMessage) UID() uint32
- type FilesystemUser
- type Mailbox
- type Mailstore
- type Message
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HeaderToString ¶
Types ¶
type DummyMailbox ¶
type DummyMailbox struct { ID uint32 // contains filtered or unexported fields }
DummyMailbox is an in-memory implementation of a Mailstore Mailbox
func (*DummyMailbox) DebugPrintMailbox ¶
func (m *DummyMailbox) DebugPrintMailbox()
DebugPrintMailbox prints out all messages in the mailbox to the command line for debugging purposes
func (*DummyMailbox) DeleteFlaggedMessages ¶
func (m *DummyMailbox) DeleteFlaggedMessages() ([]Message, error)
DeleteFlaggedMessages deletes messages marked with the Delete flag and returns them.
func (*DummyMailbox) LastUID ¶
func (m *DummyMailbox) LastUID() uint32
LastUID returns the UID of the last message in the mailbox or if the mailbox is empty, the next expected UID
func (*DummyMailbox) MessageBySequenceNumber ¶
func (m *DummyMailbox) MessageBySequenceNumber(seqno uint32) Message
MessageBySequenceNumber returns a single message given the message's sequence number
func (*DummyMailbox) MessageByUID ¶
func (m *DummyMailbox) MessageByUID(uidno uint32) Message
MessageByUID returns a single message given the message's sequence number
func (*DummyMailbox) MessageSetBySequenceNumber ¶
func (m *DummyMailbox) MessageSetBySequenceNumber(set types.SequenceSet) []Message
MessageSetBySequenceNumber returns a slice of messages given a set of sequence number ranges
func (*DummyMailbox) MessageSetByUID ¶
func (m *DummyMailbox) MessageSetByUID(set types.SequenceSet) []Message
MessageSetByUID returns a slice of messages given a set of UID ranges. eg 1,5,9,28:140,190:*
func (*DummyMailbox) Messages ¶
func (m *DummyMailbox) Messages() uint32
Messages returns the total number of messages in the Mailbox
func (*DummyMailbox) NewMessage ¶
func (m *DummyMailbox) NewMessage() Message
NewMessage creates a new message in the dummy mailbox.
func (*DummyMailbox) NextUID ¶
func (m *DummyMailbox) NextUID() uint32
NextUID returns the UID that is likely to be assigned to the next new message in the Mailbox
func (*DummyMailbox) Recent ¶
func (m *DummyMailbox) Recent() uint32
Recent returns the number of messages in the mailbox which are currently marked with the 'Recent' flag
func (*DummyMailbox) Unseen ¶
func (m *DummyMailbox) Unseen() uint32
Unseen returns the number of messages in the mailbox which are currently marked with the 'Unseen' flag
type DummyMailstore ¶
type DummyMailstore struct {
User *DummyUser
}
DummyMailstore is an in-memory mail storage for testing purposes and to provide an example implementation of a mailstore
func NewDummyMailstore ¶
func NewDummyMailstore() *DummyMailstore
NewDummyMailstore performs some initialisation and should always be used to create a new DummyMailstore
func (*DummyMailstore) Authenticate ¶
func (d *DummyMailstore) Authenticate(username string, password string) (User, error)
Authenticate implements the Authenticate method on the Mailstore interface
type DummyMessage ¶
type DummyMessage struct {
// contains filtered or unexported fields
}
DummyMessage is a representation of a single in-memory message in a DummyMailbox.
func (*DummyMessage) AddFlags ¶
func (m *DummyMessage) AddFlags(newFlags types.Flags) Message
AddFlags adds the given flag to the message.
func (*DummyMessage) Body ¶
func (m *DummyMessage) Body() string
Body returns the full body of the message
func (*DummyMessage) Flags ¶
func (m *DummyMessage) Flags() types.Flags
Flags returns any flags on the message.
func (*DummyMessage) Header ¶
func (m *DummyMessage) Header() (hdr mail.Header)
Header returns the message's MIME Header.
func (*DummyMessage) InternalDate ¶
func (m *DummyMessage) InternalDate() time.Time
InternalDate returns the internally stored date of the message
func (*DummyMessage) Keywords ¶
func (m *DummyMessage) Keywords() []string
Keywords returns any keywords associated with the message
func (*DummyMessage) OverwriteFlags ¶
func (m *DummyMessage) OverwriteFlags(newFlags types.Flags) Message
OverwriteFlags replaces any flags on the message with those specified.
func (*DummyMessage) RemoveFlags ¶
func (m *DummyMessage) RemoveFlags(newFlags types.Flags) Message
RemoveFlags removes the given flag from the message.
func (*DummyMessage) Save ¶
func (m *DummyMessage) Save() (Message, error)
Save saves the message to the mailbox it belongs to.
func (*DummyMessage) SequenceNumber ¶
func (m *DummyMessage) SequenceNumber() uint32
SequenceNumber returns the message's sequence number.
func (*DummyMessage) SetBody ¶
func (m *DummyMessage) SetBody(newBody string) Message
SetBody sets the body of the message.
func (*DummyMessage) SetHeaders ¶
func (m *DummyMessage) SetHeaders(newHeader mail.Header) Message
SetHeaders sets the e-mail headers of the message.
func (*DummyMessage) Size ¶
func (m *DummyMessage) Size() uint32
Size returns the message's full RFC822 size, including full message header and body.
func (*DummyMessage) UID ¶
func (m *DummyMessage) UID() uint32
UID returns the message's unique identifier (UID).
type DummyUser ¶
type DummyUser struct {
// contains filtered or unexported fields
}
DummyUser is an in-memory representation of a mailstore's user
func (*DummyUser) MailboxByName ¶
MailboxByName returns a DummyMailbox object, given the mailbox's name
type FilesystemMailbox ¶
type FilesystemMailbox struct { ID uint32 // contains filtered or unexported fields }
FilesystemMailbox is a filesystem implementation of a Mailstore Mailbox It points to a subdir of the Mailstore
func (*FilesystemMailbox) DebugPrintMailbox ¶
func (m *FilesystemMailbox) DebugPrintMailbox()
DebugPrintMailbox prints out all messages in the mailbox to the command line for debugging purposes
func (*FilesystemMailbox) DeleteFlaggedMessages ¶
func (m *FilesystemMailbox) DeleteFlaggedMessages() ([]Message, error)
DeleteFlaggedMessages deletes messages marked with the Delete flag and returns them. None in this read only imap server.
func (*FilesystemMailbox) LastUID ¶
func (m *FilesystemMailbox) LastUID() uint32
LastUID returns the UID of the last message in the mailbox or if the mailbox is empty, the next expected UID
func (*FilesystemMailbox) MessageBySequenceNumber ¶
func (m *FilesystemMailbox) MessageBySequenceNumber(seqno uint32) Message
MessageBySequenceNumber returns a single message given the message's sequence number
func (*FilesystemMailbox) MessageByUID ¶
func (m *FilesystemMailbox) MessageByUID(uidno uint32) Message
MessageByUID returns a single message given the message's sequence number
func (*FilesystemMailbox) MessageSetBySequenceNumber ¶
func (m *FilesystemMailbox) MessageSetBySequenceNumber(set types.SequenceSet) []Message
MessageSetBySequenceNumber returns a slice of messages given a set of sequence number ranges
func (*FilesystemMailbox) MessageSetByUID ¶
func (m *FilesystemMailbox) MessageSetByUID(set types.SequenceSet) []Message
MessageSetByUID returns a slice of messages given a set of UID ranges. eg 1,5,9,28:140,190:*
func (*FilesystemMailbox) Messages ¶
func (m *FilesystemMailbox) Messages() uint32
Messages returns the total number of messages in the Mailbox
func (*FilesystemMailbox) Name ¶
func (m *FilesystemMailbox) Name() string
Name returns the Mailbox's name func (m *FilesystemMailbox) Name() string { return m.subdirname }
func (*FilesystemMailbox) NewMessage ¶
func (m *FilesystemMailbox) NewMessage() Message
NewMessage creates a new message in the mailbox. NOTE: This should not make any changes to the mailbox until the message's `Save` method is called.
func (*FilesystemMailbox) NextUID ¶
func (m *FilesystemMailbox) NextUID() uint32
NextUID returns the UID that is likely to be assigned to the next new message in the Mailbox
func (*FilesystemMailbox) Recent ¶
func (m *FilesystemMailbox) Recent() uint32
Recent returns the number of messages in the mailbox which are currently marked with the 'Recent' flag
func (*FilesystemMailbox) Unseen ¶
func (m *FilesystemMailbox) Unseen() uint32
Unseen returns the number of messages in the mailbox which are currently marked with the 'Unseen' flag
type FilesystemMailstore ¶
type FilesystemMailstore struct {
// contains filtered or unexported fields
}
FilesystemMailstore is a filesystem mail storage It points to a dir in a filesystem
func NewFilesystemMailstore ¶
func NewFilesystemMailstore(dirname string) *FilesystemMailstore
NewFilesystemMailstore performs some initialisation and should always be used to create a new FilesystemMailstore
func (*FilesystemMailstore) Authenticate ¶
func (d *FilesystemMailstore) Authenticate(username string, password string) (User, error)
Authenticate implements the Authenticate method on the Mailstore interface
type FilesystemMessage ¶
type FilesystemMessage struct { ID uint32 // contains filtered or unexported fields }
FilesystemMessage is a representation of a single message in a FilesystemMailbox. It points to a file
func (*FilesystemMessage) AddFlags ¶
func (m *FilesystemMessage) AddFlags(newFlags types.Flags) Message
AddFlags adds the given flag to the message.
func (*FilesystemMessage) Body ¶
func (m *FilesystemMessage) Body() string
Body returns the full body of the message
func (*FilesystemMessage) Flags ¶
func (m *FilesystemMessage) Flags() types.Flags
Flags returns any flags on the message.
func (*FilesystemMessage) Header ¶
func (m *FilesystemMessage) Header() (hdr mail.Header)
Header returns the message's MIME Header.
func (*FilesystemMessage) InternalDate ¶
func (m *FilesystemMessage) InternalDate() time.Time
InternalDate returns the internally stored date of the message
func (*FilesystemMessage) Keywords ¶
func (m *FilesystemMessage) Keywords() []string
Keywords returns any keywords associated with the message
func (*FilesystemMessage) OverwriteFlags ¶
func (m *FilesystemMessage) OverwriteFlags(newFlags types.Flags) Message
OverwriteFlags replaces any flags on the message with those specified.
func (*FilesystemMessage) RemoveFlags ¶
func (m *FilesystemMessage) RemoveFlags(newFlags types.Flags) Message
RemoveFlags removes the given flag from the message.
func (*FilesystemMessage) Save ¶
func (m *FilesystemMessage) Save() (Message, error)
Save saves the message to the mailbox it belongs to.
func (*FilesystemMessage) SequenceNumber ¶
func (m *FilesystemMessage) SequenceNumber() uint32
SequenceNumber returns the message's sequence number.
func (*FilesystemMessage) SetBody ¶
func (m *FilesystemMessage) SetBody(newBody string) Message
SetBody sets the body of the message.
func (*FilesystemMessage) SetHeaders ¶
func (m *FilesystemMessage) SetHeaders(newHeader mail.Header) Message
SetHeaders sets the e-mail headers of the message.
func (*FilesystemMessage) Size ¶
func (m *FilesystemMessage) Size() uint32
Size returns the message's full RFC822 size, including full message header and body.
func (*FilesystemMessage) UID ¶
func (m *FilesystemMessage) UID() uint32
UID returns the message's unique identifier (UID).
type FilesystemUser ¶
type FilesystemUser struct {
// contains filtered or unexported fields
}
FilesystemUser is a representation of a user
func (FilesystemUser) MailboxByName ¶
func (u FilesystemUser) MailboxByName(name string) (Mailbox, error)
MailboxByName implements the MailboxByName method on the User interface
func (FilesystemUser) Mailboxes ¶
func (u FilesystemUser) Mailboxes() []Mailbox
Mailboxes implements the Mailboxes method on the User interface
type Mailbox ¶
type Mailbox interface { // The name of the mailbox Name() string // The unique identifier that will LIKELY be assigned // to the next mail that is added to this mailbox NextUID() uint32 // The UID of the very last message in the mailbox // If the mailbox is empty, this should return the next expected UID LastUID() uint32 // Number of recent messages in the mailbox Recent() uint32 // Number of messages in the mailbox Messages() uint32 // Number messages that do not have the Unseen flag set yet Unseen() uint32 // Get a message by its sequence number MessageBySequenceNumber(seqno uint32) Message // Get a message by its uid number MessageByUID(uidno uint32) Message // Get messages that belong to a set of ranges of UIDs MessageSetByUID(set types.SequenceSet) []Message // Get messages that belong to a set of ranges of sequence numbers MessageSetBySequenceNumber(set types.SequenceSet) []Message // Creates a new (empty) message that belongs to this mailbox // NOTE: This should not make any changes to the mailbox until the // message's `Save` method is called. NewMessage() Message // DeleteFlaggedMessages deletes messages marked with the Delete flag and // returns them. It also updates the sequence numbers of all messages in the // mailbox to account for the deleted messages. DeleteFlaggedMessages() ([]Message, error) }
Mailbox represents a mailbox belonging to a user in the mail storage system
type Mailstore ¶
type Mailstore interface { // Attempt to authenticate a user with given credentials, // and return the user if successful Authenticate(username string, password string) (User, error) }
Mailstore is an interface to be implemented to provide mail storage
type Message ¶
type Message interface { // Return the message's MIME headers as a map in format // key: value Header() mail.Header // Return the unique id of the email UID() uint32 // Return the sequence number of the email SequenceNumber() uint32 // Return the RFC822 size of the message Size() uint32 // Return the date the email was received by the server // (This is not the date on the envelope of the email) InternalDate() time.Time // Return the body of the email Body() string // Return the list of custom keywords/flags for this message Keywords() []string // Get the flags for this message Flags() types.Flags // Overwrite the flags for this message and return the updated message OverwriteFlags(types.Flags) Message // Write the flags for this message and return the updated message AddFlags(types.Flags) Message // Write the flags for this message and return the updated message RemoveFlags(types.Flags) Message // Overwrite the message headers SetHeaders(mail.Header) Message // Overwrite the message body SetBody(string) Message // Save any changes to the message Save() (Message, error) }
Message represents a standard email message