mailcmd

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: GPL-3.0 Imports: 3 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.

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 Sender

type Sender func(msg *mail.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