imap

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const GenerateBufferSize = 100

Variables

This section is empty.

Functions

func Validate

func Validate(s *models.IMAP) error

Validate validates supplied IMAP model by connecting to the server

Types

type Client

type Client interface {
	Close(expunge bool) (cmd *imap.Command, err error)
	Login(username, password string) (cmd *imap.Command, err error)
	Logout(timeout time.Duration) (cmd *imap.Command, err error)
	Select(mbox string, readonly bool) (cmd *imap.Command, err error)
	UIDFetch(seq *imap.SeqSet, items ...string) (cmd *imap.Command, err error)
	UIDSearch(spec ...imap.Field) (cmd *imap.Command, err error)
	UIDStore(seq *imap.SeqSet, item string, value imap.Field) (cmd *imap.Command, err error)
}

Client interface for IMAP interactions

type Email

type Email struct {
	UID uint32 `json:"uid"`
	*email.Email
}

Email represents an email.Email with an included IMAP UID

func NewEmail

func NewEmail(msgFields imap.FieldMap) (Email, error)

NewEmail will parse an imap.FieldMap into an Email. This will expect the message to container the internaldate and the body with all headers included.

type Mailbox

type Mailbox struct {
	Host   string
	TLS    bool
	User   string
	Pwd    string
	Folder string
	// Read only mode, false (original logic) if not initialized
	ReadOnly bool
}

Mailbox holds onto the credentials and other information needed for connecting to an IMAP server.

func (*Mailbox) DeleteEmails

func (mbox *Mailbox) DeleteEmails(uids []uint32) error

DeleteEmails will delete emails from the supplied slice of UIDs

func (*Mailbox) GenerateAll

func (mbox *Mailbox) GenerateAll(markAsRead, delete bool) (chan Response, error)

GenerateAll will find all emails in the email folder and pass them along to the responses channel.

func (*Mailbox) GenerateUnread

func (mbox *Mailbox) GenerateUnread(markAsRead, delete bool) (chan Response, error)

GenerateUnread will find all unread emails in the folder and pass them along to the responses channel.

func (*Mailbox) GetAll

func (mbox *Mailbox) GetAll(markAsRead, delete bool) ([]Email, error)

GetAll will pull all emails from the email folder and return them as a list.

func (*Mailbox) GetUnread

func (mbox *Mailbox) GetUnread(markAsRead, delete bool) ([]Email, error)

GetUnread will find all unread emails in the folder and return them as a list.

func (*Mailbox) MarkAsUnread

func (mbox *Mailbox) MarkAsUnread(uids []uint32) error

MarkAsUnread will set the UNSEEN flag on a supplied slice of UIDs

type Monitor

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

Monitor is a worker that monitors IMAP servers for reported campaign emails

func NewMonitor

func NewMonitor() *Monitor

NewMonitor returns a new instance of imap.Monitor

func (*Monitor) Shutdown

func (im *Monitor) Shutdown() error

Shutdown attempts to gracefully shutdown the IMAP monitor.

func (*Monitor) Start

func (im *Monitor) Start() error

Start launches the IMAP campaign monitor

type Response

type Response struct {
	Email Email
	Err   error
}

Response is a helper struct to wrap the email responses and possible errors.

Jump to

Keyboard shortcuts

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