mailcmd

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mailcmd composes an email message and either writes it to a writer or sends it via an injected sender. It backs the span-mail command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cfg Config, w io.Writer, send Sender) error

Run composes the message. If w is non-nil the composed message is written to it (the -o path); otherwise it is handed to send.

func Send added in v0.3.4

func Send(addr string, auth smtp.Auth, msg *Message) error

Send sends the message via the given SMTP server address (host:port). Auth may be nil for unauthenticated relays.

Types

type Config

type Config struct {
	From       string
	To         []string
	Subject    string
	Body       string
	SMTPServer string
}

Config holds the fields needed to compose a message. Body is the already-read message body (main reads the -b file); SMTPServer is the host part of the server address ("" if a composed-message writer is used instead).

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the required fields are present.

type Message added in v0.3.4

type Message struct {
	From       string
	To         []string
	Subject    string
	Body       string
	Precedence string // e.g. "bulk"; left empty if not needed
}

Message represents an email message.

func (*Message) Bytes added in v0.3.4

func (m *Message) Bytes() []byte

Bytes composes the raw RFC 2822 message.

type Sender

type Sender func(msg *Message) error

Sender sends a composed message. It is injected so Run can be tested without touching the network; the default sender talks SMTP.

func DefaultSender

func DefaultSender(server string) Sender

DefaultSender sends the message via SMTP to server:25 with no auth.

Jump to

Keyboard shortcuts

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