imapreader

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2015 License: MIT Imports: 5 Imported by: 0

README

go-imapreader Build Status GoDoc

Simple interface for reading IMAP emails in Golang

Documentation

Index

Constants

View Source
const (
	// GMail inbox mailbox
	GMailInbox string = "INBOX"
	// GMail all mail mailbox
	GMailAllMail string = "[Gmail]/All Mail"
)

Variables

View Source
var (
	// Search only the unseen messages
	SearchUnseen = []imap.Field{"UNSEEN"}
	// Search all messages
	SearchAll = []imap.Field{"ALL"}
	// Search only answered messages
	SearchAnswered = []imap.Field{"ANSWERED"}
	// Search only unanswered messages
	SearchUnanswered = []imap.Field{"UNANSWERED"}
	// Search only deleted messages
	SearchDeleted = []imap.Field{"DELETED"}
	// Search only not deleted messages
	SearchUndeleted = []imap.Field{"UNDELETED"}
	// Search only flagged messages
	SearchFlagged = []imap.Field{"FLAGGED"}
	// Search only not flagged messages
	SearchUnflagged = []imap.Field{"UNFLAGGED"}
	// Search only new messages
	SearchNew = []imap.Field{"NEW"}
	// Search only old messages
	SearchOld = []imap.Field{"OLD"}
	// Search only recent messages
	SearchRecent = []imap.Field{"RECENT"}
	// Search only seen messages
	SearchSeen = []imap.Field{"SEEN"}
)

Functions

func ByFrom

func ByFrom(from string) []imap.Field

ByFrom returns the search parameters to perform a search by FROM address

func BySubject

func BySubject(subject string) []imap.Field

BySubject returns the search paramters to perform a search by subject

Types

type Email

type Email struct {
	// Array of flags the message has
	Flags []string
	// Contains all the message headers
	Header mail.Header
	// Contains the message body
	Body []byte
}

type Options

type Options struct {
	// IMAP server address with port
	Addr string
	// Username
	Username string
	// Password
	Password string
	// Use TLS for the connection
	TLS bool
	// Max timeout for logging out
	Timeout time.Duration
	// Mark all the retrieved messages as seen when retrieved
	MarkSeen bool
}

Options define the settings to perform all the reader operations

type Reader

type Reader interface {
	Login() error
	Logout() error
	List(string, []imap.Field) ([]*Email, error)
}

Reader is a client to read messages from an IMAP server only contains the List operation as well as login and logout operations

func NewReader

func NewReader(opts Options) (Reader, error)

NewReader constructs a new Reader instance with the given Options

Jump to

Keyboard shortcuts

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