mail

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mail builds and sends AgentTransfer's outbound email and parses inbound email.

Outbound messages are ordinary multipart/mixed emails: a human-readable text body plus the machine-readable AgentTransfer manifest attached as application/vnd.agenttransfer+json. Sending goes through the operator's relay (any SMTP submission endpoint — Resend, SES, Postmark, ...); AgentTransfer never sends from its own IP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAgentMessageID

func ExtractAgentMessageID(rfcID string) string

ExtractAgentMessageID pulls an AgentTransfer "msg_..." id out of an RFC Message-ID like "<msg_abc@host>", or returns "".

func FormatRFCMessageID

func FormatRFCMessageID(msgID, domain string) string

FormatRFCMessageID renders an AgentTransfer message id as an RFC Message-ID.

func Send

func Send(o *Outbound, envelopeFrom string, rcpts []string, raw []byte) error

Send submits raw message bytes through the relay for the given envelope.

func TestAuth

func TestAuth(o *Outbound) error

TestAuth connects and authenticates against the relay without sending — used by `agenttransfer doctor`.

Types

type InAttachment

type InAttachment struct {
	Name string
	MIME string
	Data []byte
}

InAttachment is one attachment from an inbound email.

type Inbound

type Inbound struct {
	From        string
	To          []string
	Subject     string
	Text        string
	MessageID   string
	InReplyTo   string
	References  string
	Manifest    []byte // raw agenttransfer.json bytes, if present
	Attachments []InAttachment
}

Inbound is a parsed inbound email.

func ParseInbound

func ParseInbound(r io.Reader, maxAttachment int64) (*Inbound, error)

ParseInbound parses a raw inbound message. Attachments larger than maxAttachment bytes are skipped (the text and manifest are always kept).

type Message

type Message struct {
	FromName   string
	From       string
	To         []string
	CC         []string
	Subject    string
	Text       string
	MessageID  string // full RFC id, e.g. <msg_x@domain>
	InReplyTo  string
	References string
	// Manifest is attached as application/vnd.agenttransfer+json when set.
	Manifest     []byte
	ManifestName string
}

Message is an outbound email under construction.

func (*Message) Build

func (m *Message) Build() ([]byte, error)

Build renders the message to raw RFC 5322 bytes.

type Outbound

type Outbound struct {
	Host     string // host:port
	HostOnly string
	User     string
	Pass     string
	Implicit bool // smtps:// — implicit TLS instead of STARTTLS
}

Outbound is a parsed OUTBOUND relay configuration.

func ParseOutbound

func ParseOutbound(s string) (*Outbound, error)

ParseOutbound parses an OUTBOUND value:

resend:re_xxxx                     (sugar for Resend's SMTP endpoint)
smtp://user:pass@host:587          (STARTTLS submission)
smtps://user:pass@host:465         (implicit TLS)

Jump to

Keyboard shortcuts

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