jmap

package
v0.0.0-...-dbf8b16 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package jmap fetches email messages from a JMAP Mail server.

https://jmap.io/spec-core.html, https://datatracker.ietf.org/doc/rfc8620/
https://jmap.io/spec-mail.html, https://datatracker.ietf.org/doc/rfc8621/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	// ID uniquely identifies the message.
	ID string `json:"id"`
	// BlobID uniquely identifies the message's content.
	BlobID string `json:"blobId"`
	// Size contains the message's raw data size in octets.
	Size uint64 `json:"size"`
	// ReceivedAt is the time the message was received by the server.
	ReceivedAt time.Time `json:"receivedAt"`
	// From contains the message's sender.
	From []EmailAddress `json:"from"`
	// Subject contains the message's subject.
	Subject string `json:"subject"`
}

Email describes an email message on the server.

type EmailAddress

type EmailAddress struct {
	// Email contains the actual email address, e.g. "[email protected]".
	Email string `json:"email"`
	// Name contains the name associated with the address, if any.
	Name string `json:"name"`
}

EmailAddress describes an email address in a message header.

type QueryConfig

type QueryConfig struct {
	// After is an inclusive lower bound for messages' "receivedAt" dates.
	After time.Time
	// Before is an exclusive upper bound for messages' "receivedAt" dates.
	Before time.Time
	// MailboxName is the name of a mailbox that messages must be in, e.g. "Inbox" or "Sent".
	MailboxName string
	// NotOnlyMailboxNames indicates that messages must be in at least one mailbox other than these.
	// Common values are "Trash" and "Spam".
	NotOnlyMailboxNames []string
	// TotalEmailsOut is set (if non-nil) to the total number of messages before any writes to ch occur.
	TotalEmailsOut *uint64
	// GetDetails controls whether the ReceivedAt, From, and Subject fields are fetched.
	GetDetails bool
}

QueryConfig configures Query's behavior.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is a JMAP Mail session.

func NewSession

func NewSession(ctx context.Context, url, token string) (*Session, error)

NewSession returns a new JMAP session initialized from the supplied JMAP Session resource URL. The supplied token is sent in an Authorization bearer header.

func (*Session) Download

func (s *Session) Download(ctx context.Context, blobID string) (io.ReadCloser, error)

Download fetches the message identified by blobID. The caller must close the returned io.ReadCloser iff error is nil.

func (*Session) GetMailboxNames

func (s *Session) GetMailboxNames(ctx context.Context) ([]string, error)

GetMailboxNames returns the names of all mailboxes.

func (*Session) Query

func (s *Session) Query(ctx context.Context, cfg QueryConfig, ch chan<- Email) error

Query fetches information about messages. Results are written to ch, which is always closed before returning.

Jump to

Keyboard shortcuts

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