Documentation
¶
Overview ¶
Package imap provides a simple, pragmatic IMAP client for Go.
It focuses on the handful of operations most applications need:
- Connecting over TLS (STARTTLS not required)
- Authenticating with LOGIN or XOAUTH2 (OAuth 2.0)
- Selecting/Examining folders, searching (UID SEARCH), and fetching messages
- Moving, copying, and appending messages
- Creating, deleting, and renaming folders
- Setting flags, deleting + expunging
- Type-safe search builder (Search().From("x").Unseen().Since(date))
- IMAP IDLE with callbacks for EXISTS/EXPUNGE/FETCH
- Automatic reconnect with re-authentication and folder restore
The API is intentionally small and easy to adopt without pulling in a full IMAP stack. See the README for end-to-end examples and guidance.
Index ¶
- Constants
- Variables
- func GetTokenName(tokenType TType) string
- func IsLiteral(b rune) bool
- func MakeIMAPLiteral(s string) string
- func SetLogger(logger Logger)
- func SetSlogLogger(logger *slog.Logger)
- type Attachment
- type Dialer
- func (d *Dialer) Append(folder string, flags []string, date time.Time, message []byte) error
- func (d *Dialer) Authenticate(user string, accessToken string) (err error)
- func (d *Dialer) CheckType(token *Token, acceptableTypes []TType, tks []*Token, loc string, v ...any) (err error)
- func (d *Dialer) Clone() (d2 *Dialer, err error)
- func (d *Dialer) Close() (err error)
- func (d *Dialer) CopyEmail(uid int, folder string) error
- func (d *Dialer) CreateFolder(name string) error
- func (d *Dialer) DeleteEmail(uid int) (err error)
- func (d *Dialer) DeleteFolder(name string) error
- func (d *Dialer) ExamineFolder(folder string) (err error)
- func (d *Dialer) Exec(command string, buildResponse bool, retryCount int, ...) (response string, err error)
- func (d *Dialer) Expunge() (err error)
- func (d *Dialer) GetEmails(uids ...int) (emails map[int]*Email, err error)
- func (d *Dialer) GetFolderStats() ([]FolderStats, error)
- func (d *Dialer) GetFolderStatsExcluding(excludedFolders []string) ([]FolderStats, error)
- func (d *Dialer) GetFolderStatsStartingFrom(startFolder string) ([]FolderStats, error)
- func (d *Dialer) GetFolderStatsStartingFromExcluding(startFolder string, excludedFolders []string) ([]FolderStats, error)
- func (d *Dialer) GetFolders() (folders []string, err error)
- func (d *Dialer) GetLastNUIDs(n int) ([]int, error)
- func (d *Dialer) GetMaxUID() (uid int, err error)
- func (d *Dialer) GetOverviews(uids ...int) (emails map[int]*Email, err error)
- func (d *Dialer) GetTotalEmailCount() (count int, err error)
- func (d *Dialer) GetTotalEmailCountExcluding(excludedFolders []string) (count int, err error)
- func (d *Dialer) GetTotalEmailCountSafe() (count int, folderErrors []error, err error)
- func (d *Dialer) GetTotalEmailCountSafeExcluding(excludedFolders []string) (count int, folderErrors []error, err error)
- func (d *Dialer) GetTotalEmailCountSafeStartingFrom(startFolder string) (count int, folderErrors []error, err error)
- func (d *Dialer) GetTotalEmailCountSafeStartingFromExcluding(startFolder string, excludedFolders []string) (count int, folderErrors []error, 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) MarkSeen(uid int) (err error)
- func (d *Dialer) MoveEmail(uid int, folder string) (err error)
- func (d *Dialer) ParseFetchResponse(responseBody string) (records [][]*Token, err error)
- func (d *Dialer) Reconnect() (err error)
- func (d *Dialer) RenameFolder(oldName, newName string) error
- func (d *Dialer) SearchUIDs(search *SearchBuilder) ([]int, error)
- func (d *Dialer) SelectFolder(folder string) (err error)
- func (d *Dialer) SetFlags(uid int, flags Flags) (err error)
- func (d *Dialer) StartIdle(handler *IdleHandler) error
- func (d *Dialer) State() int
- func (d *Dialer) StopIdle() error
- type Email
- type EmailAddresses
- type ExistsEvent
- type ExpungeEvent
- type FetchEvent
- type FlagSet
- type Flags
- type FolderStats
- type IdleHandler
- type Logger
- type SearchBuilder
- func (s *SearchBuilder) All() *SearchBuilder
- func (s *SearchBuilder) Answered() *SearchBuilder
- func (s *SearchBuilder) BCC(addr string) *SearchBuilder
- func (s *SearchBuilder) Before(t time.Time) *SearchBuilder
- func (s *SearchBuilder) Body(text string) *SearchBuilder
- func (s *SearchBuilder) Build() string
- func (s *SearchBuilder) CC(addr string) *SearchBuilder
- func (s *SearchBuilder) Deleted() *SearchBuilder
- func (s *SearchBuilder) Draft() *SearchBuilder
- func (s *SearchBuilder) Flagged() *SearchBuilder
- func (s *SearchBuilder) From(addr string) *SearchBuilder
- func (s *SearchBuilder) Header(field, value string) *SearchBuilder
- func (s *SearchBuilder) Keyword(keyword string) *SearchBuilder
- func (s *SearchBuilder) Larger(bytes int) *SearchBuilder
- func (s *SearchBuilder) New() *SearchBuilder
- func (s *SearchBuilder) Not(inner *SearchBuilder) *SearchBuilder
- func (s *SearchBuilder) Old() *SearchBuilder
- func (s *SearchBuilder) On(t time.Time) *SearchBuilder
- func (s *SearchBuilder) Or(a, b *SearchBuilder) *SearchBuilder
- func (s *SearchBuilder) Recent() *SearchBuilder
- func (s *SearchBuilder) Seen() *SearchBuilder
- func (s *SearchBuilder) SentBefore(t time.Time) *SearchBuilder
- func (s *SearchBuilder) SentOn(t time.Time) *SearchBuilder
- func (s *SearchBuilder) SentSince(t time.Time) *SearchBuilder
- func (s *SearchBuilder) Since(t time.Time) *SearchBuilder
- func (s *SearchBuilder) Smaller(bytes int) *SearchBuilder
- func (s *SearchBuilder) Subject(subject string) *SearchBuilder
- func (s *SearchBuilder) Text(text string) *SearchBuilder
- func (s *SearchBuilder) To(addr string) *SearchBuilder
- func (s *SearchBuilder) UID(set string) *SearchBuilder
- func (s *SearchBuilder) Unanswered() *SearchBuilder
- func (s *SearchBuilder) Undeleted() *SearchBuilder
- func (s *SearchBuilder) Undraft() *SearchBuilder
- func (s *SearchBuilder) Unflagged() *SearchBuilder
- func (s *SearchBuilder) Unkeyword(keyword string) *SearchBuilder
- func (s *SearchBuilder) Unseen() *SearchBuilder
- type TType
- type Token
Constants ¶
const ( StateDisconnected = iota StateConnected StateSelected StateIdlePending StateIdling StateStoppingIdle )
Connection state constants
const ( IdleEventExists = "EXISTS" IdleEventExpunge = "EXPUNGE" IdleEventFetch = "FETCH" )
IDLE event type constants
const ( EDate uint8 = iota ESubject EFrom ESender EReplyTo ETo ECC EBCC EInReplyTo EMessageID )
Email parsing constants
const ( EEName uint8 = iota EESR EEMailbox EEHost )
const (
TimeFormat = "_2-Jan-2006 15:04:05 -0700"
)
Variables ¶
var ( AddSlashes = strings.NewReplacer(`"`, `\"`) RemoveSlashes = strings.NewReplacer(`\"`, `"`) )
String replacers for escaping/unescaping quotes
var CommandTimeout time.Duration
CommandTimeout defines how long to wait for a command to complete. Zero means no timeout.
var DialTimeout time.Duration
DialTimeout defines how long to wait when establishing a new connection. Zero means no timeout.
var RetryCount = 10
var SkipResponses = false
SkipResponses skips printing server responses in verbose mode
var TLSSkipVerify bool
TLSSkipVerify disables certificate verification when establishing new connections. Use with caution; skipping verification exposes the connection to man-in-the-middle attacks.
var Verbose = false
Verbose outputs every command and its response with the IMAP server
Functions ¶
func GetTokenName ¶
GetTokenName returns the string name of a token type
func IsLiteral ¶
IsLiteral checks if a rune is valid for a literal token.
This matches RFC 3501 ATOM-CHAR (plus '\' and ']' for flag and BODY[...] syntax): any character except atom-specials ("(", ")", "{", SP, CTL, list-wildcards, quoted-specials). Custom IMAP keyword flags commonly use '$', '-', '_', '+', etc. — rejecting those chars caused flags like "$X-ME-Annot-2" (Fastmail) to be split across multiple tokens. See issue #90.
func MakeIMAPLiteral ¶ added in v0.1.16
MakeIMAPLiteral generates IMAP literal syntax for non-ASCII strings. It returns a string in the format "{bytecount}\r\ntext" where bytecount is the number of bytes (not characters) in the input string. This is useful for search queries with non-ASCII characters. Example: MakeIMAPLiteral("тест") returns "{8}\r\nтест"
func SetLogger ¶ added in v0.1.17
func SetLogger(logger Logger)
SetLogger replaces the global logger used by the package. Passing nil restores the built-in slog logger.
func SetSlogLogger ¶ added in v0.1.17
SetSlogLogger is a convenience helper for using a *slog.Logger directly.
Types ¶
type Attachment ¶
Attachment represents an email attachment
func (Attachment) String ¶
func (a Attachment) String() string
String returns a formatted string representation of an Attachment
type Dialer ¶
type Dialer struct {
Folder string
ReadOnly bool
Username string
Password string
Host string
Port int
Connected bool
ConnNum int
// contains filtered or unexported fields
}
Dialer represents 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 creates a new IMAP connection using OAuth2 authentication
func (*Dialer) Append ¶ added in v0.1.25
Append uploads a message to the specified folder.
The flags parameter specifies initial flags for the message (e.g., `\Seen`, `\Draft`). Pass nil or an empty slice for no flags. The date parameter sets the internal date; pass a zero time.Time to let the server use the current time.
The message parameter should be a complete RFC 2822 message (headers + body).
Note: Append does not retry on failure because the IMAP APPEND protocol uses a two-phase literal transfer. A partial send cannot be safely retried without risking duplicate messages.
Example:
msg := []byte("From: a@b.com\r\nTo: c@d.com\r\nSubject: Hi\r\n\r\nHello!")
err := conn.Append("INBOX", []string{`\Seen`}, time.Time{}, msg)
func (*Dialer) Authenticate ¶ added in v0.1.7
Authenticate performs XOAUTH2 authentication using an access token
func (*Dialer) CheckType ¶
func (d *Dialer) CheckType(token *Token, acceptableTypes []TType, tks []*Token, loc string, v ...any) (err error)
CheckType validates that a token is one of the acceptable types
func (*Dialer) CopyEmail ¶ added in v0.1.25
CopyEmail copies an email to a different folder. Unlike MoveEmail, the original message remains in the current folder. UID COPY is not retried because duplicating a message is not idempotent.
func (*Dialer) CreateFolder ¶ added in v0.1.25
CreateFolder creates a new mailbox with the given name. This command is not retried because CREATE is not idempotent.
func (*Dialer) DeleteEmail ¶ added in v0.1.9
DeleteEmail marks an email for deletion
func (*Dialer) DeleteFolder ¶ added in v0.1.25
DeleteFolder permanently removes a mailbox. If the deleted folder is currently selected, the folder state is cleared. This command is not retried because DELETE is not idempotent.
func (*Dialer) ExamineFolder ¶ added in v0.1.8
ExamineFolder selects a folder in read-only mode
func (*Dialer) Exec ¶
func (d *Dialer) Exec(command string, buildResponse bool, retryCount int, processLine func(line []byte) error) (response string, err error)
Exec executes an IMAP command with retry logic and response building
func (*Dialer) GetFolderStats ¶ added in v0.1.16
func (d *Dialer) GetFolderStats() ([]FolderStats, error)
GetFolderStats returns statistics for all folders
func (*Dialer) GetFolderStatsExcluding ¶ added in v0.1.16
func (d *Dialer) GetFolderStatsExcluding(excludedFolders []string) ([]FolderStats, error)
GetFolderStatsExcluding returns statistics for folders excluding specified ones
func (*Dialer) GetFolderStatsStartingFrom ¶ added in v0.1.16
func (d *Dialer) GetFolderStatsStartingFrom(startFolder string) ([]FolderStats, error)
GetFolderStatsStartingFrom returns statistics for folders starting from a specific one
func (*Dialer) GetFolderStatsStartingFromExcluding ¶ added in v0.1.16
func (d *Dialer) GetFolderStatsStartingFromExcluding(startFolder string, excludedFolders []string) ([]FolderStats, error)
GetFolderStatsStartingFromExcluding returns detailed statistics for folders with options
func (*Dialer) GetFolders ¶
GetFolders retrieves the list of available folders
func (*Dialer) GetLastNUIDs ¶ added in v0.1.20
GetLastNUIDs returns the N messages with the highest UIDs in the selected folder. This is useful for fetching the most recent messages.
Note: This method fetches all UIDs from the server and returns the last N. For mailboxes with many thousands of messages, consider using GetUIDs with a specific UID range if you know the approximate UID values you need.
Example:
// Get the 10 most recent messages uids, err := conn.GetLastNUIDs(10)
func (*Dialer) GetMaxUID ¶ added in v0.1.24
Get max UID in the current folder using RFC-4731.
The folder of interest must be already selected in either read-only mode, ExamineFolder, or in read-write mode, SelectFolder.
func (*Dialer) GetOverviews ¶
GetOverviews retrieves email overview information (headers, flags, etc.)
func (*Dialer) GetTotalEmailCount ¶
GetTotalEmailCount returns the total email count across all folders
func (*Dialer) GetTotalEmailCountExcluding ¶
GetTotalEmailCountExcluding returns total email count excluding specified folders
func (*Dialer) GetTotalEmailCountSafe ¶ added in v0.1.16
GetTotalEmailCountSafe returns total email count with error handling per folder
func (*Dialer) GetTotalEmailCountSafeExcluding ¶ added in v0.1.16
func (d *Dialer) GetTotalEmailCountSafeExcluding(excludedFolders []string) (count int, folderErrors []error, err error)
GetTotalEmailCountSafeExcluding returns total email count excluding folders with error handling
func (*Dialer) GetTotalEmailCountSafeStartingFrom ¶ added in v0.1.16
func (d *Dialer) GetTotalEmailCountSafeStartingFrom(startFolder string) (count int, folderErrors []error, err error)
GetTotalEmailCountSafeStartingFrom returns total email count starting from folder with error handling
func (*Dialer) GetTotalEmailCountSafeStartingFromExcluding ¶ added in v0.1.16
func (d *Dialer) GetTotalEmailCountSafeStartingFromExcluding(startFolder string, excludedFolders []string) (count int, folderErrors []error, err error)
GetTotalEmailCountSafeStartingFromExcluding returns total email count with per-folder error handling
func (*Dialer) GetTotalEmailCountStartingFrom ¶
GetTotalEmailCountStartingFrom returns total email count starting from a specific folder
func (*Dialer) GetTotalEmailCountStartingFromExcluding ¶
func (d *Dialer) GetTotalEmailCountStartingFromExcluding(startFolder string, excludedFolders []string) (count int, err error)
GetTotalEmailCountStartingFromExcluding returns total email count with options for starting folder and exclusions
func (*Dialer) GetUIDs ¶
GetUIDs retrieves message UIDs matching a search criteria. The search parameter is passed directly to the IMAP UID SEARCH command. See RFC 3501 for search criteria syntax.
Common examples:
- "ALL" - all messages
- "UNSEEN" - unread messages
- "SEEN" - read messages
- "1:10" - UIDs 1 through 10
- "SINCE 1-Jan-2024" - messages since a date
Note: For retrieving the N most recent messages, use GetLastNUIDs instead.
func (*Dialer) ParseFetchResponse ¶
ParseFetchResponse parses a multi-line FETCH response
func (*Dialer) RenameFolder ¶ added in v0.1.25
RenameFolder renames a mailbox from oldName to newName. If the renamed folder is currently selected, the tracked folder name is updated. This command is not retried because RENAME is not idempotent.
func (*Dialer) SearchUIDs ¶ added in v0.1.25
func (d *Dialer) SearchUIDs(search *SearchBuilder) ([]int, error)
SearchUIDs executes a search using the builder and returns matching UIDs.
Example:
uids, err := conn.SearchUIDs(imap.Search().From("alice@example.com").Unseen())
func (*Dialer) SelectFolder ¶
SelectFolder selects a folder in read-write mode
func (*Dialer) StartIdle ¶ added in v0.1.5
func (d *Dialer) StartIdle(handler *IdleHandler) error
StartIdle starts IDLE monitoring with automatic reconnection and timeout handling
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 represents an IMAP email message
type EmailAddresses ¶
EmailAddresses represents a map of email addresses to display names
func (EmailAddresses) String ¶
func (e EmailAddresses) String() string
String returns a formatted string representation of EmailAddresses
type ExistsEvent ¶ added in v0.1.5
type ExistsEvent struct {
MessageIndex int
}
ExistsEvent represents an EXISTS event from IDLE
type ExpungeEvent ¶ added in v0.1.5
type ExpungeEvent struct {
MessageIndex int
}
ExpungeEvent represents an EXPUNGE event from IDLE
type FetchEvent ¶ added in v0.1.5
FetchEvent represents a FETCH event from IDLE
type Flags ¶ added in v0.1.8
type Flags struct {
Seen FlagSet
Answered FlagSet
Flagged FlagSet
Deleted FlagSet
Draft FlagSet
Keywords map[string]bool
}
Flags represents standard IMAP message flags
type FolderStats ¶ added in v0.1.16
FolderStats represents statistics for a folder
type IdleHandler ¶ added in v0.1.5
type IdleHandler struct {
OnExists func(event ExistsEvent)
OnExpunge func(event ExpungeEvent)
OnFetch func(event FetchEvent)
}
IdleHandler provides callbacks for IDLE events
type Logger ¶ added in v0.1.17
type Logger interface {
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
WithAttrs(args ...any) Logger
}
Logger defines the minimal logging interface used by the IMAP client.
Implementations must be safe for concurrent use.
func SlogLogger ¶ added in v0.1.17
SlogLogger adapts a *slog.Logger to the Logger interface.
type SearchBuilder ¶ added in v0.1.25
type SearchBuilder struct {
// contains filtered or unexported fields
}
SearchBuilder constructs IMAP SEARCH criteria using a fluent builder pattern. All criteria are AND-ed together (IMAP implicit conjunction).
Example:
uids, err := conn.SearchUIDs(
imap.Search().From("alice@example.com").Unseen().Since(lastWeek),
)
func (*SearchBuilder) All ¶ added in v0.1.25
func (s *SearchBuilder) All() *SearchBuilder
All matches all messages.
func (*SearchBuilder) Answered ¶ added in v0.1.25
func (s *SearchBuilder) Answered() *SearchBuilder
Answered matches messages with the \Answered flag.
func (*SearchBuilder) BCC ¶ added in v0.1.25
func (s *SearchBuilder) BCC(addr string) *SearchBuilder
BCC matches messages with the specified string in the BCC header.
func (*SearchBuilder) Before ¶ added in v0.1.25
func (s *SearchBuilder) Before(t time.Time) *SearchBuilder
Before matches messages with an internal date before the given date.
func (*SearchBuilder) Body ¶ added in v0.1.25
func (s *SearchBuilder) Body(text string) *SearchBuilder
Body matches messages with the specified string in the message body.
func (*SearchBuilder) Build ¶ added in v0.1.25
func (s *SearchBuilder) Build() string
Build returns the assembled IMAP SEARCH criteria string. If no criteria have been added, it returns "ALL". CHARSET UTF-8 is prepended when any criterion contains non-ASCII text.
func (*SearchBuilder) CC ¶ added in v0.1.25
func (s *SearchBuilder) CC(addr string) *SearchBuilder
CC matches messages with the specified string in the CC header.
func (*SearchBuilder) Deleted ¶ added in v0.1.25
func (s *SearchBuilder) Deleted() *SearchBuilder
Deleted matches messages with the \Deleted flag.
func (*SearchBuilder) Draft ¶ added in v0.1.25
func (s *SearchBuilder) Draft() *SearchBuilder
Draft matches messages with the \Draft flag.
func (*SearchBuilder) Flagged ¶ added in v0.1.25
func (s *SearchBuilder) Flagged() *SearchBuilder
Flagged matches messages with the \Flagged flag.
func (*SearchBuilder) From ¶ added in v0.1.25
func (s *SearchBuilder) From(addr string) *SearchBuilder
From matches messages with the specified string in the From header.
func (*SearchBuilder) Header ¶ added in v0.1.25
func (s *SearchBuilder) Header(field, value string) *SearchBuilder
Header matches messages with the specified value in the named header field.
func (*SearchBuilder) Keyword ¶ added in v0.1.25
func (s *SearchBuilder) Keyword(keyword string) *SearchBuilder
Keyword matches messages with the specified keyword flag.
func (*SearchBuilder) Larger ¶ added in v0.1.25
func (s *SearchBuilder) Larger(bytes int) *SearchBuilder
Larger matches messages with a size (in bytes) greater than the specified value.
func (*SearchBuilder) New ¶ added in v0.1.25
func (s *SearchBuilder) New() *SearchBuilder
New matches messages that are both \Recent and not \Seen.
func (*SearchBuilder) Not ¶ added in v0.1.25
func (s *SearchBuilder) Not(inner *SearchBuilder) *SearchBuilder
Not negates the given search criteria.
Example:
// Messages NOT from alice
Search().Not(Search().From("alice@example.com"))
func (*SearchBuilder) Old ¶ added in v0.1.25
func (s *SearchBuilder) Old() *SearchBuilder
Old matches messages without the \Recent flag.
func (*SearchBuilder) On ¶ added in v0.1.25
func (s *SearchBuilder) On(t time.Time) *SearchBuilder
On matches messages with an internal date equal to the given date.
func (*SearchBuilder) Or ¶ added in v0.1.25
func (s *SearchBuilder) Or(a, b *SearchBuilder) *SearchBuilder
Or matches messages that satisfy either set of criteria. IMAP OR takes exactly two search keys.
Example:
// Messages from alice OR bob
Search().Or(Search().From("alice"), Search().From("bob"))
func (*SearchBuilder) Recent ¶ added in v0.1.25
func (s *SearchBuilder) Recent() *SearchBuilder
Recent matches messages with the \Recent flag.
func (*SearchBuilder) Seen ¶ added in v0.1.25
func (s *SearchBuilder) Seen() *SearchBuilder
Seen matches messages with the \Seen flag.
func (*SearchBuilder) SentBefore ¶ added in v0.1.25
func (s *SearchBuilder) SentBefore(t time.Time) *SearchBuilder
SentBefore matches messages with a Date header before the given date.
func (*SearchBuilder) SentOn ¶ added in v0.1.25
func (s *SearchBuilder) SentOn(t time.Time) *SearchBuilder
SentOn matches messages with a Date header equal to the given date.
func (*SearchBuilder) SentSince ¶ added in v0.1.25
func (s *SearchBuilder) SentSince(t time.Time) *SearchBuilder
SentSince matches messages with a Date header on or after the given date.
func (*SearchBuilder) Since ¶ added in v0.1.25
func (s *SearchBuilder) Since(t time.Time) *SearchBuilder
Since matches messages with an internal date on or after the given date.
func (*SearchBuilder) Smaller ¶ added in v0.1.25
func (s *SearchBuilder) Smaller(bytes int) *SearchBuilder
Smaller matches messages with a size (in bytes) less than the specified value.
func (*SearchBuilder) Subject ¶ added in v0.1.25
func (s *SearchBuilder) Subject(subject string) *SearchBuilder
Subject matches messages with the specified string in the Subject header.
func (*SearchBuilder) Text ¶ added in v0.1.25
func (s *SearchBuilder) Text(text string) *SearchBuilder
Text matches messages with the specified string in the header or body.
func (*SearchBuilder) To ¶ added in v0.1.25
func (s *SearchBuilder) To(addr string) *SearchBuilder
To matches messages with the specified string in the To header.
func (*SearchBuilder) UID ¶ added in v0.1.25
func (s *SearchBuilder) UID(set string) *SearchBuilder
UID matches messages in the specified UID set (e.g., "1:100", "5,10,15").
func (*SearchBuilder) Unanswered ¶ added in v0.1.25
func (s *SearchBuilder) Unanswered() *SearchBuilder
Unanswered matches messages without the \Answered flag.
func (*SearchBuilder) Undeleted ¶ added in v0.1.25
func (s *SearchBuilder) Undeleted() *SearchBuilder
Undeleted matches messages without the \Deleted flag.
func (*SearchBuilder) Undraft ¶ added in v0.1.25
func (s *SearchBuilder) Undraft() *SearchBuilder
Undraft matches messages without the \Draft flag.
func (*SearchBuilder) Unflagged ¶ added in v0.1.25
func (s *SearchBuilder) Unflagged() *SearchBuilder
Unflagged matches messages without the \Flagged flag.
func (*SearchBuilder) Unkeyword ¶ added in v0.1.25
func (s *SearchBuilder) Unkeyword(keyword string) *SearchBuilder
Unkeyword matches messages without the specified keyword flag.
func (*SearchBuilder) Unseen ¶ added in v0.1.25
func (s *SearchBuilder) Unseen() *SearchBuilder
Unseen matches messages without the \Seen flag.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic_connection
command
|
|
|
complete_example
command
|
|
|
email_operations
command
|
|
|
error_handling
command
|
|
|
fetch_emails
command
|
|
|
folders
command
|
|
|
idle_monitoring
command
|
|
|
literal_search
command
|
|
|
oauth2_connection
command
|
|
|
search
command
|