Documentation
¶
Overview ¶
Package devmail is the Dev Portal's mail catcher (ADR-0074): an SMTP server inside orb dev that keeps every message the app sends under .orb/portal/mail, parsed for the inbox screen. It speaks the SMTP the app's sender needs in development (no TLS, no authentication) and nothing more; it must never listen beyond the loopback interface.
Index ¶
- Constants
- Variables
- func Parse(raw []byte) (Summary, Detail, error)
- type Address
- type Attachment
- type Detail
- type Envelope
- type Link
- type Server
- type Store
- func (s *Store) Add(_ context.Context, from string, rcpts []string, raw []byte) (Summary, error)
- func (s *Store) Clear() error
- func (s *Store) Count() int
- func (s *Store) Delete(id string) error
- func (s *Store) Get(id string) (Detail, error)
- func (s *Store) List(q string, limit int) ([]Summary, int)
- func (s *Store) Source(id string) ([]byte, error)
- func (s *Store) Subscribe() (<-chan Summary, func())
- type Summary
Constants ¶
const ( // MaxMessages is how many messages the inbox keeps; older ones are // deleted first. MaxMessages = 500 // Dir is where the messages live, inside the app. Dir = ".orb/portal/mail" )
Limits of the store.
const (
// MaxMessageBytes is the largest message accepted.
MaxMessageBytes = 16 << 20
)
Limits of a session.
Variables ¶
var ErrNotFound = errors.New("no such message")
ErrNotFound reports a message ID the store doesn't have.
Functions ¶
Types ¶
type Attachment ¶
type Attachment struct {
Name string `json:"name"`
ContentType string `json:"content_type"`
Size int `json:"size"`
}
Attachment describes a part with a file name.
type Detail ¶
type Detail struct {
Summary
ReplyTo []Address `json:"reply_to,omitempty"`
CC []Address `json:"cc,omitempty"`
Headers map[string]string `json:"headers"`
Text string `json:"text"`
HTML string `json:"html"`
Links []Link `json:"links"`
Attachment []Attachment `json:"attachment_list"`
MessageID string `json:"message_id,omitempty"`
Envelope Envelope `json:"envelope"`
SourceBytes int64 `json:"source_bytes"`
}
Detail is a message with its bodies.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server receives messages into a Store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps messages as .eml files with a JSON summary next to each, and serves them to the portal. It is safe for concurrent use.
func Open ¶
Open opens the store under the app directory dir, creating it, and reads the summaries it has.
func (*Store) List ¶
List returns the messages newest first, those matching q (a case-insensitive substring of the subject, addresses or snippet) when q isn't empty, at most limit (default 100).
type Summary ¶
type Summary struct {
ID string `json:"id"`
Time time.Time `json:"time"`
From Address `json:"from"`
To []Address `json:"to"`
Subject string `json:"subject"`
Snippet string `json:"snippet"`
Size int64 `json:"size"`
HasHTML bool `json:"has_html"`
HasText bool `json:"has_text"`
Codes []string `json:"codes"`
Category string `json:"category,omitempty"`
// Attachments counts them; the detail lists them.
Attachments int `json:"attachments"`
Read bool `json:"read"`
}
Summary is a message in the list.