go_email

package module
v0.0.0-...-19729dd Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig(configsPath string) (map[string]EmailConfig, error)

Types

type Crit

type Crit struct {
	Since      time.Time
	Before     time.Time
	SentSince  time.Time
	SentBefore time.Time

	From []string
	To   []string
	Bcc  []string
	Cc   []string

	Body []string
	Text []string

	WithFlags []string
}

func (*Crit) ToSearchCriteria

func (c *Crit) ToSearchCriteria() (*imap.SearchCriteria, error)

type Defaults

type Defaults struct {
	Inbox string `json:"inbox"`
	Trash string `json:"trash"`
	Spam  string `json:"spam"`
}

type EmailClient

type EmailClient struct {
	Platform string
	Token    *oauth2.Token
	Client   *client.Client

	EmailAddress string
	Auth         sasl.Client
}

func NewEmailClient

func NewEmailClient(cfg string) (EmailClient, error)

func (*EmailClient) AllInOneAuth

func (ec *EmailClient) AllInOneAuth(username string, config oauth2.Config) (oauth2.Token, error)

func (*EmailClient) Authenticate

func (ec *EmailClient) Authenticate(username string) error

func (*EmailClient) DialTlsImap

func (ec *EmailClient) DialTlsImap(imap string) error

func (*EmailClient) GetBody

func (ec *EmailClient) GetBody(uid uint32, mbox string) (imap.Message, imap.BodySectionName, error)

func (*EmailClient) GetByMessageId

func (ec *EmailClient) GetByMessageId(messageId string, mbox string) ([]uint32, error)

func (*EmailClient) GetByUID

func (ec *EmailClient) GetByUID(uid uint32) ([]uint32, error)

func (*EmailClient) GetEnvelopes

func (ec *EmailClient) GetEnvelopes(from uint32, to uint32) []Envelope

func (*EmailClient) GetEnvelopesFromSeqArr

func (ec *EmailClient) GetEnvelopesFromSeqArr(msgs []uint32, mailbox string) ([]Envelope, error)

func (*EmailClient) GetEnvelopesFromUIDArr

func (ec *EmailClient) GetEnvelopesFromUIDArr(msgs []uint32, mailbox string) ([]Envelope, error)

func (*EmailClient) GetHtml

func (ec *EmailClient) GetHtml(uid uint32, mbox string) (string, error)

func (*EmailClient) GetLast

func (ec *EmailClient) GetLast(amount uint32, defaultInbox string) (uint32, uint32)

func (*EmailClient) GetMailBoxes

func (ec *EmailClient) GetMailBoxes() ([]imap.MailboxInfo, error)

func (*EmailClient) GetPage

func (ec *EmailClient) GetPage(page int32, perPage int32) (uint32, uint32)

func (*EmailClient) GetPreview

func (ec *EmailClient) GetPreview(uid uint32, previewCharSize int, mbox string) (MessagePart, error)

func (*EmailClient) GetPreviewAndICS

func (ec *EmailClient) GetPreviewAndICS(uid uint32, previewCharSize int, mbox string) (MessagePart, MessagePart, error)

func (*EmailClient) GetToken

func (ec *EmailClient) GetToken(code string, config *oauth2.Config) error

func (*EmailClient) LogOut

func (ec *EmailClient) LogOut() error

func (*EmailClient) ParseMessage

func (ec *EmailClient) ParseMessage(msg imap.Message, section imap.BodySectionName) (Message, error)

func (*EmailClient) SearchByCrit

func (ec *EmailClient) SearchByCrit(crit Crit) ([]uint32, error)

func (*EmailClient) SelectMailBox

func (ec *EmailClient) SelectMailBox(mName string) error

func (*EmailClient) SendMail

func (ec *EmailClient) SendMail(smtpAddress string, to []string, bcc []string, cc []string, replyTo string, subject string, msgBody string) error

func (*EmailClient) SetTokenVals

func (ec *EmailClient) SetTokenVals(accessToken, expiry, refreshToken string, tokenType string) error

type EmailConfig

type EmailConfig struct {
	Defaults    map[string]string `json:"defaults"`
	Smtp        string            `json:"smtp"`
	Imap        string            `json:"imap"`
	AuthURI     string            `json:"authURI"`
	ExchangeURI string            `json:"exchangeURI"`
	Config      oauth2.Config     `json:"config"`
	AltClientId string            `json:"altClientId"`
}

type Envelope

type Envelope struct {
	Envelope imap.Envelope
	Flags    []string
	Uid      uint32
	Mbox     string
	Address  string
}

type Message

type Message struct {
	Attachments []MessagePart
	Html        MessagePart
	Raw         MessagePart
	Header      mail.Header
}

type MessagePart

type MessagePart struct {
	Name     string
	PartType string
	Part     []byte
}

Jump to

Keyboard shortcuts

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