Documentation ¶
Index ¶
- Constants
- Variables
- func GetTokenName(tokenType TType) string
- func IsLiteral(b rune) bool
- type Attachment
- type Dialer
- func (d *Dialer) Authenticate(user string, accessToken string) (err error)
- func (d *Dialer) CheckType(token *Token, acceptableTypes []TType, tks []*Token, loc string, ...) (err error)
- func (d *Dialer) Clone() (d2 *Dialer, err error)
- func (d *Dialer) Close() (err error)
- func (d *Dialer) Exec(command string, buildResponse bool, retryCount int, ...) (response string, err error)
- func (d *Dialer) GetEmails(uids ...int) (emails map[int]*Email, err error)
- func (d *Dialer) GetFolders() (folders []string, err error)
- func (d *Dialer) GetOverviews(uids ...int) (emails map[int]*Email, err error)
- func (d *Dialer) GetStrtokI() int
- func (d *Dialer) GetTotalEmailCount() (count int, err error)
- func (d *Dialer) GetTotalEmailCountExcluding(excludedFolders []string) (count int, err error)
- func (d *Dialer) GetTotalEmailCountStartingFrom(startFolder string) (count int, err error)
- func (d *Dialer) GetTotalEmailCountStartingFromExcluding(startFolder string, excludedFolders []string) (count int, err error)
- func (d *Dialer) GetUIDs(search string) (uids []int, err error)
- func (d *Dialer) Login(username string, password string) (err error)
- func (d *Dialer) MoveEmail(uid int, folder string) (err error)
- func (d *Dialer) ParseFetchResponse(r string) (records [][]*Token, err error)
- func (d *Dialer) Reconnect() (err error)
- func (d *Dialer) SelectFolder(folder string) (err error)
- func (d *Dialer) StartIdle(handler *IdleHandler) error
- func (d *Dialer) Strtok(delims []byte) string
- func (d *Dialer) StrtokInit(b string, delims []byte) string
- type Email
- type EmailAddresses
- type ExistsEvent
- type ExpungeEvent
- type FetchEvent
- type IdleHandler
- type TType
- type Token
Constants ¶
const ( IdleEventExists = "EXISTS" IdleEventExpunge = "EXPUNGE" IdleEventFetch = "FETCH" )
const ( EDate uint8 = iota ESubject EFrom ESender EReplyTo ETo ECC EBCC EInReplyTo EMessageID )
const ( EEName uint8 = iota // EESR is unused and should be ignored EESR EEMailbox EEHost )
const TimeFormat = "_2-Jan-2006 15:04:05 -0700"
TimeFormat is the Go time version of the IMAP times
Variables ¶
var AddSlashes = strings.NewReplacer(`"`, `\"`)
AddSlashes adds slashes to double quotes
var RemoveSlashes = strings.NewReplacer(`\"`, `"`)
RemoveSlashes removes slashes before double quotes
var RetryCount = 10
RetryCount is the number of times retired functions get retried
var SkipResponses = false
SkipResponses skips printing server responses in verbose mode
var Verbose = false
Verbose outputs every command and its response with the IMAP server
Functions ¶
func GetTokenName ¶
GetTokenName returns the name of the given token type token
Types ¶
type Attachment ¶
Attachment is an Email attachment
func (Attachment) String ¶
func (a Attachment) String() string
type Dialer ¶
type Dialer struct { Folder string Username string Password string Host string Port int Connected bool ConnNum int // contains filtered or unexported fields }
Dialer is basically an IMAP connection
func NewWithOAuth2 ¶ added in v0.1.7
func NewWithOAuth2(username string, accessToken string, host string, port int) (d *Dialer, err error)
NewWithOAuth2 makes a new imap with OAuth2
func (*Dialer) Authenticate ¶ added in v0.1.7
func (*Dialer) CheckType ¶
func (d *Dialer) CheckType(token *Token, acceptableTypes []TType, tks []*Token, loc string, v ...interface{}) (err error)
CheckType validates a type against a list of acceptable types, if the type of the token isn't in the list, an error is returned
func (*Dialer) Clone ¶
Clone returns a new connection with the same connection information as the one this is being called on
func (*Dialer) Exec ¶
func (d *Dialer) Exec(command string, buildResponse bool, retryCount int, processLine func(line []byte) error) (response string, err error)
Exec executes the command on the imap connection
func (*Dialer) GetEmails ¶
GetEmails returns email with their bodies for the given UIDs in the current folder. If no UIDs are given, they everything in the current folder is selected
func (*Dialer) GetFolders ¶
GetFolders returns all folders
func (*Dialer) GetOverviews ¶
GetOverviews returns emails without bodies for the given UIDs in the current folder. If no UIDs are given, they everything in the current folder is selected
func (*Dialer) GetStrtokI ¶
GetStrtokI returns the current position of the tokenizer
func (*Dialer) GetTotalEmailCount ¶
GetTotalEmailCount returns the total number of emails in every folder
func (*Dialer) GetTotalEmailCountExcluding ¶
GetTotalEmailCountExcluding returns the total number of emails in every folder excluding the specified folders
func (*Dialer) GetTotalEmailCountStartingFrom ¶
GetTotalEmailCountStartingFrom returns the total number of emails in every folder after the specified start folder
func (*Dialer) GetTotalEmailCountStartingFromExcluding ¶
func (d *Dialer) GetTotalEmailCountStartingFromExcluding(startFolder string, excludedFolders []string) (count int, err error)
GetTotalEmailCountStartingFromExcluding returns the total number of emails in every folder after the specified start folder, excluding the specified folders
func (*Dialer) ParseFetchResponse ¶
ParseFetchResponse parses a response from a FETCH command into tokens
func (*Dialer) Reconnect ¶
Reconnect closes the current connection (if any) and establishes a new one
func (*Dialer) SelectFolder ¶
SelectFolder selects a folder
func (*Dialer) StartIdle ¶ added in v0.1.5
func (d *Dialer) StartIdle(handler *IdleHandler) error
type Email ¶
type Email struct { Flags []string Received time.Time Sent time.Time Size uint64 Subject string UID int MessageID string From EmailAddresses To EmailAddresses ReplyTo EmailAddresses CC EmailAddresses BCC EmailAddresses Text string HTML string Attachments []Attachment }
Email is an email message
type EmailAddresses ¶
EmailAddresses are a map of email address to names
func (EmailAddresses) String ¶
func (e EmailAddresses) String() string
type ExistsEvent ¶ added in v0.1.5
type ExistsEvent struct {
MessageIndex int
}
type ExpungeEvent ¶ added in v0.1.5
type ExpungeEvent struct {
MessageIndex int
}
type FetchEvent ¶ added in v0.1.5
type IdleHandler ¶ added in v0.1.5
type IdleHandler struct { OnExists func(event ExistsEvent) OnExpunge func(event ExpungeEvent) OnFetch func(event FetchEvent) }
type TType ¶
type TType uint8
TType is the enum type for token values
const ( // TUnset is an unset token; used by the parser TUnset TType = iota // TAtom is a string that's prefixed with `{n}` // where n is the number of bytes in the string TAtom // TNumber is a numeric literal TNumber // TLiteral is a literal (think string, ish, used mainly for field names, I hope) TLiteral // TQuoted is a quoted piece of text TQuoted // TNil is a nil value, nothing TNil // TContainer is a container of tokens TContainer )