mail

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Service *gmail.Service

Functions

func Archive

func Archive(id string) error

func CreateDraft added in v1.1.4

func CreateDraft(opts MessageOptions) (string, error)

func DeleteDraft added in v1.1.4

func DeleteDraft(id string) error

func ExtractBody

func ExtractBody(msg *gmail.Message) string

func ExtractHeader

func ExtractHeader(msg *gmail.Message, name string) string

func GetAllRecipients

func GetAllRecipients(msg *gmail.Message) (to string, cc string)

func GetDraft added in v1.1.4

func GetDraft(id string) (*gmail.Draft, error)

func GetLastMessageInThread

func GetLastMessageInThread(threadID string) (*gmail.Message, error)

func GetOriginalMessageID

func GetOriginalMessageID(msg *gmail.Message) string

func GetReferences

func GetReferences(msg *gmail.Message) string

func GetSignature

func GetSignature(sendAsEmail string) (string, error)

func GetThread

func GetThread(id string) (*gmail.Thread, error)

func GetThreadMetadata

func GetThreadMetadata(ctx context.Context, id string) (*gmail.Thread, error)

func HTMLText added in v1.1.4

func HTMLText(s string) string

Unescaped plain text spliced into an HTML body loses every line break, and any markup-shaped run (a bare "<bob@x.com>") is swallowed.

func Init

func Init(client *http.Client) error

func MarkRead

func MarkRead(id string) error

func MarkSpam

func MarkSpam(id string) error

func MarkUnread

func MarkUnread(id string) error

func SendDraft added in v1.1.4

func SendDraft(id string) (threadID string, err error)

func SendMessage

func SendMessage(opts MessageOptions) (threadID string, err error)

func Star

func Star(id string) error

func StripQuotedText added in v1.1.4

func StripQuotedText(body string) string

func Trash

func Trash(id string) error

func Unstar

func Unstar(id string) error

func UpdateDraft added in v1.1.4

func UpdateDraft(id string, opts MessageOptions) error

Types

type Attachment added in v1.1.4

type Attachment struct {
	Filename string
	MimeType string
	Data     []byte
}

func LoadAttachments added in v1.1.4

func LoadAttachments(paths []string) ([]Attachment, error)

type DraftOverlay added in v1.1.4

type DraftOverlay struct {
	To                *[]string
	Cc                *[]string
	Bcc               *[]string
	Subject           *string
	Body              *string
	ContentType       *string
	AppendAttachments []Attachment
}

DraftOverlay is a proposed draft edit: a nil field carries the base value forward, a non-nil field replaces it (a non-nil pointer to an empty value clears the field — the "-s \"\" clears vs omitted carries forward" rule). AppendAttachments are always added to the base's carried attachments.

type DraftSummary added in v1.1.4

type DraftSummary struct {
	ID      string
	To      string
	Subject string
	Updated string
}

func ListDrafts added in v1.1.4

func ListDrafts(ctx context.Context, limit int64) ([]DraftSummary, error)

type MessageOptions

type MessageOptions struct {
	To          []string
	Cc          []string
	Bcc         []string
	Subject     string
	Body        string
	ContentType string
	InReplyTo   string
	References  string
	ThreadId    string
	Attachments []Attachment
}

func ApplyDraftOverlay added in v1.1.4

func ApplyDraftOverlay(base MessageOptions, ov DraftOverlay) MessageOptions

func BuildForwardOptions added in v1.1.4

func BuildForwardOptions(threadID string, to []string, note string, contentType string, extraAttachments []Attachment) (MessageOptions, error)

func BuildReplyOptions added in v1.1.4

func BuildReplyOptions(threadID string, body string, contentType string, replyAll bool, attachments []Attachment) (MessageOptions, error)

func DraftToOptions added in v1.1.4

func DraftToOptions(d *gmail.Draft) (MessageOptions, error)

The body is normalized to plain text so draft-edit re-composes as text/plain.

type ThreadSummary

type ThreadSummary struct {
	ID           string
	From         string
	Subject      string
	Date         string
	Snippet      string
	Unread       bool
	MessageCount int
}

func ListThreads

func ListThreads(ctx context.Context, label string, unread bool, count int64) ([]ThreadSummary, error)

func SearchThreads

func SearchThreads(ctx context.Context, query string, max int64) ([]ThreadSummary, error)

Jump to

Keyboard shortcuts

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