Documentation
¶
Index ¶
- func Folders(acct EmailAccount) ([]string, error)
- func FormatDryRun(acct EmailAccount, opts SendOptions) string
- func MarkSeen(acct EmailAccount, folder string, uid uint32, seen bool) error
- func SaveAttachments(acct EmailAccount, folder string, uid uint32, dir string) ([]string, error)
- func Send(acct EmailAccount, opts SendOptions) error
- func ValidateAccountName(name string) error
- type AttachmentInfo
- type Config
- type EmailAccount
- type Envelope
- type ListOptions
- type Message
- type SendOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Folders ¶
func Folders(acct EmailAccount) ([]string, error)
Folders returns a sorted list of mailbox names available on the server.
func FormatDryRun ¶
func FormatDryRun(acct EmailAccount, opts SendOptions) string
FormatDryRun returns a human-readable representation of the email that would be sent, for use with --dry-run.
func MarkSeen ¶ added in v0.26.0
func MarkSeen(acct EmailAccount, folder string, uid uint32, seen bool) error
MarkSeen adds or removes the \Seen flag on a message identified by UID. seen=true marks the message as read; seen=false marks it as unread.
func SaveAttachments ¶
SaveAttachments downloads and saves all attachments of a message to dir. It returns the list of file paths written.
func Send ¶
func Send(acct EmailAccount, opts SendOptions) error
Send composes and sends an email via SMTP using the provided account configuration.
func ValidateAccountName ¶
Types ¶
type AttachmentInfo ¶
type AttachmentInfo struct {
Filename string `json:"filename"`
Size int64 `json:"size"`
MIMEType string `json:"mime_type"`
}
AttachmentInfo holds metadata about a message attachment (no content).
type Config ¶
type Config struct {
Default string `json:"default"`
Accounts map[string]EmailAccount `json:"accounts"`
}
func LoadFromEnv ¶
func (*Config) AccountNames ¶
func (*Config) SetDefault ¶
func (*Config) Upsert ¶
func (c *Config) Upsert(name string, partial EmailAccount)
type EmailAccount ¶
type EmailAccount struct {
IMAPHost string `json:"imap_host,omitempty"`
IMAPPort int `json:"imap_port,omitempty"`
IMAPTLS string `json:"imap_tls,omitempty"`
SMTPHost string `json:"smtp_host,omitempty"`
SMTPPort int `json:"smtp_port,omitempty"`
SMTPTLS string `json:"smtp_tls,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
From string `json:"from,omitempty"`
}
type Envelope ¶
type Envelope struct {
UID uint32 `json:"uid"`
MessageID string `json:"message_id,omitempty"`
From string `json:"from"`
FromName string `json:"from_name,omitempty"`
FromAddr string `json:"from_addr,omitempty"`
To []string `json:"to"`
Subject string `json:"subject"`
Date time.Time `json:"date"`
Flags []string `json:"flags"`
HasAttachments bool `json:"has_attachments"`
Size int64 `json:"size"`
}
Envelope holds metadata about an email message.
func List ¶
func List(acct EmailAccount, opts ListOptions) ([]Envelope, error)
List returns envelope metadata for messages in the given folder, filtered by opts.
type ListOptions ¶
type ListOptions struct {
Folder string
Limit int
Unread bool
From string
Subject string
Since *time.Time
Before *time.Time
}
ListOptions controls which messages are returned by List.
type Message ¶
type Message struct {
Envelope
TextBody string `json:"text_body,omitempty"`
HTMLBody string `json:"html_body,omitempty"`
Attachments []AttachmentInfo `json:"attachments,omitempty"`
}
Message is a fully-fetched email message including body and attachment metadata.
type SendOptions ¶
type SendOptions struct {
To []string
Cc []string
Bcc []string
Subject string
Body string
HTML bool
Attachments []string // file paths
From string // override sender
ReplyTo string
InReplyTo string // Message-ID of the message being replied to
}
SendOptions holds the parameters for composing and sending an email.