maildev

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package maildev contains the opt-in MailDev REST compatibility contract.

Index

Constants

View Source
const (
	DefaultPageSize = 50
	MaxPageSize     = 200
	PreviewLength   = 140
)

Variables

This section is empty.

Functions

func EmbedAttachmentURLs

func EmbedAttachmentURLs(html, basePath, emailID string, attachments []Attachment) string

EmbedAttachmentURLs replaces MailDev-style CID references with facade URLs.

func MatchesFilters

func MatchesFilters(email Email, filters map[string]string) bool

MatchesFilters applies MailDev's exact, case-sensitive query-string field matching to a compatibility DTO.

func ParseNonNegativeInt

func ParseNonNegativeInt(value string) (int, bool)

Types

type Address

type Address struct {
	Address string `json:"address"`
	Name    string `json:"name,omitempty"`
}

type Attachment

type Attachment struct {
	Filename           string `json:"filename"`
	GeneratedFileName  string `json:"generatedFileName"`
	ContentType        string `json:"contentType"`
	ContentDisposition string `json:"contentDisposition"`
	ContentID          string `json:"contentId,omitempty"`
	Size               int64  `json:"size,omitempty"`
}

type BulkDeleteResponse

type BulkDeleteResponse struct {
	Deleted  []string `json:"deleted"`
	NotFound []string `json:"notFound"`
}

type ConfigResponse

type ConfigResponse struct {
	Version         string  `json:"version"`
	SMTPPort        int     `json:"smtpPort"`
	OutgoingEnabled bool    `json:"isOutgoingEnabled"`
	OutgoingHost    *string `json:"outgoingHost"`
}

type Email

type Email struct {
	ID            string                 `json:"id"`
	Time          time.Time              `json:"time"`
	Read          bool                   `json:"read"`
	Subject       string                 `json:"subject"`
	Source        string                 `json:"source"`
	Size          int64                  `json:"size"`
	SizeHuman     string                 `json:"sizeHuman"`
	From          []Address              `json:"from"`
	To            []Address              `json:"to"`
	CC            []Address              `json:"cc,omitempty"`
	BCC           []Address              `json:"bcc,omitempty"`
	CalculatedBCC []Address              `json:"calculatedBcc"`
	Date          *time.Time             `json:"date,omitempty"`
	HTML          string                 `json:"html,omitempty"`
	Text          string                 `json:"text,omitempty"`
	Headers       map[string]interface{} `json:"headers"`
	InReplyTo     string                 `json:"inReplyTo,omitempty"`
	Priority      string                 `json:"priority,omitempty"`
	Attachments   []Attachment           `json:"attachments"`
	Envelope      Envelope               `json:"envelope"`
}

Email is deliberately independent from OwlMail's native DTO. Its JSON names, optional fields, envelope shape, and attachment shape follow MailDev's REST contract without changing /api/v1.

func FilterAndPage

func FilterAndPage(emails []Email, filters map[string]string, skip int, limit *int, order string) []Email

func FromEmail

func FromEmail(email *types.Email, mailDir string) Email

type Envelope

type Envelope struct {
	From          EnvelopeAddress   `json:"from"`
	To            []EnvelopeAddress `json:"to"`
	Host          string            `json:"host,omitempty"`
	RemoteAddress string            `json:"remoteAddress,omitempty"`
}

type EnvelopeAddress

type EnvelopeAddress struct {
	Address string `json:"address"`
}

type Summary

type Summary struct {
	ID              string    `json:"id"`
	Time            time.Time `json:"time"`
	Read            bool      `json:"read"`
	Subject         string    `json:"subject"`
	Size            int64     `json:"size"`
	SizeHuman       string    `json:"sizeHuman"`
	From            []Address `json:"from"`
	To              []Address `json:"to"`
	CC              []Address `json:"cc,omitempty"`
	AttachmentCount int       `json:"attachmentCount"`
	Preview         string    `json:"preview"`
}

func FromEmailSummary

func FromEmailSummary(email mailserver.EmailSummary) Summary

FromEmailSummary maps the mailbox's lightweight summary projection into the MailDev DTO without requiring a complete message clone.

func ToSummary

func ToSummary(email *types.Email) Summary

type SummaryResponse

type SummaryResponse struct {
	Items      []Summary `json:"items"`
	Total      int       `json:"total"`
	StoreTotal int       `json:"storeTotal"`
	Unread     int       `json:"unread"`
	Skip       int       `json:"skip"`
	Limit      int       `json:"limit"`
}

Jump to

Keyboard shortcuts

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