Documentation
¶
Index ¶
- func GetMessages(client Client, mailbox string, ids ...uint32) ([]*imap.Message, error)
- func ListMailboxes(client Client) ([]*imap.MailboxInfo, error)
- func ListMessages(client Client, mailbox string) ([]*imap.Message, error)
- func NewAuth(username string, password string) sasl.Client
- func NewSMTPClient(auth sasl.Client, address string) (*smtp.Client, error)
- func NewTLSClient(auth sasl.Client, address string) (*client.Client, error)
- func SendMessage(client SMTPClient, msg []byte) error
- type Client
- type Message
- type SMTPClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMessages ¶
GetMessages returns 1 or more messages given their ids from a single given mailbox
func ListMailboxes ¶
func ListMailboxes(client Client) ([]*imap.MailboxInfo, error)
ListMailboxes collects all available mailboxes of an IMAP account and returns them in a slice TODO: implement limits, pagination, or splitting by folder level to handle cases of large or complex folder structures
func ListMessages ¶
ListMessages returns all messages in a given imap mailbox TODO: add limits or pagination for large amounts of messages
func NewAuth ¶
NewAuth returns a sasl Plain auth client to use for authenticating to IMAP and SMTP servers.
func NewSMTPClient ¶
NewSMTPClient creates a new authenticated TLS client using Plain auth and returns a ready to use client for SMTP operations. The caller is responsible for calling client.Quit()
func NewTLSClient ¶
NewTLSClient creates a new authenticated TLS client using Plain auth and returns a ready to use client for IMAP operations. The caller is responsible for calling client.Logout()
func SendMessage ¶
func SendMessage(client SMTPClient, msg []byte) error
SendMessage accepts a message, does some parsing and validation of the From and To addresses and sends via SMTP
Types ¶
type Client ¶
type Client interface {
List(string, string, chan *imap.MailboxInfo) error
Fetch(*imap.SeqSet, []imap.FetchItem, chan *imap.Message) error
Select(string, bool) (*imap.MailboxStatus, error)
Logout() error
}
Client provides the necessary functions for listing and fetching IMAP mailboxes and messages. A go-imap *client.Client is a valid implementation.