mailview

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mailview turns JMAP emails into compact, model-friendly values.

Index

Constants

This section is empty.

Variables

View Source
var BodyProperties = []string{"partId", "blobId", "size", "name", "type", "charset", "disposition", "cid"}

BodyProperties are the body part properties fetched with FullProperties.

View Source
var FullProperties = []string{"id", "threadId", "mailboxIds", "keywords", "receivedAt", "sentAt", "from", "to", "cc", "bcc", "replyTo", "sender",
	"subject", "messageId", "inReplyTo", "references", "textBody", "htmlBody", "attachments", "bodyValues", "size", "hasAttachment", "preview"}

FullProperties are the Email properties needed by Full.

View Source
var SummaryProperties = []string{"id", "threadId", "mailboxIds", "keywords", "receivedAt", "from", "to", "subject", "preview", "hasAttachment", "attachments", "size"}

SummaryProperties are the Email properties needed by Summarize.

Functions

func Address

func Address(a *mail.Address) string

Address formats a JMAP address as "Name <addr>".

func Addresses

func Addresses(as []*mail.Address) []string

Addresses formats a list of JMAP addresses.

func BodyText

func BodyText(e *email.Email) (text string, fromHTML, truncated bool)

BodyText returns the plain text of an email, converting HTML when no text part exists.

func Flags

func Flags(kw map[string]bool) []string

Flags maps JMAP keywords to short flag names; unread is the absence of $seen.

func HTMLToText

func HTMLToText(html string) string

HTMLToText renders HTML as plain text without executing anything.

func MailboxNames

func MailboxNames(ids map[jmap.ID]bool, names map[jmap.ID]string) []string

MailboxNames maps the ids of an email to mailbox names.

func Truncate

func Truncate(s string, max int) (string, bool)

Truncate cuts s to at most max runes; max <= 0 means no limit.

Types

type Attachment

type Attachment struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	Type string `json:"type,omitempty"`
	Size uint64 `json:"size"`
}

Attachment describes a downloadable part.

type Message

type Message struct {
	ID            string       `json:"id"`
	Thread        string       `json:"thread"`
	Mailboxes     []string     `json:"mailboxes,omitempty"`
	Flags         []string     `json:"flags,omitempty"`
	ReceivedAt    string       `json:"received_at,omitempty"`
	SentAt        string       `json:"sent_at,omitempty"`
	From          []string     `json:"from,omitempty"`
	Sender        []string     `json:"sender,omitempty"`
	ReplyTo       []string     `json:"reply_to,omitempty"`
	To            []string     `json:"to,omitempty"`
	Cc            []string     `json:"cc,omitempty"`
	Bcc           []string     `json:"bcc,omitempty"`
	Subject       string       `json:"subject"`
	MessageID     []string     `json:"message_id,omitempty"`
	InReplyTo     []string     `json:"in_reply_to,omitempty"`
	References    []string     `json:"references,omitempty"`
	Body          string       `json:"body"`
	BodyTruncated bool         `json:"body_truncated,omitempty"`
	BodyLength    int          `json:"body_length"`
	BodyFromHTML  bool         `json:"body_from_html,omitempty"`
	Attachments   []Attachment `json:"attachments,omitempty"`
}

Message is the full form of an email.

func Full

func Full(e *email.Email, mailboxes map[jmap.ID]string, maxChars int) Message

Full builds the complete form of an email, with its body cut to maxChars runes.

type Summary

type Summary struct {
	ID          string   `json:"id"`
	Thread      string   `json:"thread"`
	Date        string   `json:"date,omitempty"`
	From        string   `json:"from,omitempty"`
	To          []string `json:"to,omitempty"`
	Subject     string   `json:"subject"`
	Preview     string   `json:"preview,omitempty"`
	Flags       []string `json:"flags,omitempty"`
	Mailboxes   []string `json:"mailboxes,omitempty"`
	Attachments int      `json:"attachments,omitempty"`
	Size        uint64   `json:"size,omitempty"`
}

Summary is the compact form of an email returned by searches.

func Summarize

func Summarize(e *email.Email, mailboxes map[jmap.ID]string) Summary

Summarize builds the compact form of an email.

Jump to

Keyboard shortcuts

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