mailcmd

package
v0.0.0-...-2db35d6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CommandTimeoutSec is the timeout used for executing app commands found in mail.
	CommandTimeoutSec = 120

	// MaxMailSizeForAppCommand is the maximum size of an incoming mail that may carry an app command.
	// The command runner will not look for app command in a mail larger than this size
	MaxMailSizeForAppCommand = 16 * toolbox.MaxCmdLength
)
View Source
const DefaultHTTPUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36"
View Source
const UndocumentedHTTPTimeoutSec = 30

Variables

View Source
var (
	TestUndocumented1Message = ""
	TestWolframAlpha         = toolbox.WolframAlpha{}
	TestUndocumented2Message = ""
	TestUndocumented3Message = ""
)
View Source
var TestUndocumented1 = Undocumented1{} // Details are set by init_mail_test.go
View Source
var TestUndocumented2 = Undocumented2{} // Details are set by init_mail_test.go
View Source
var TestUndocumented3 = Undocumented3{} // Details are set by init_mail_test.go
View Source
var TestUndocumented3Mail inet.BasicMail // Details are set by init_mail_test.go

Functions

func TestCommandRunner

func TestCommandRunner(runner *CommandRunner, t testingstub.T)

Run unit tests on mail processor. See TestMailProcessor_Process for processor setup.

Types

type CommandRunner

type CommandRunner struct {
	Undocumented1   Undocumented1             `json:"Undocumented1"` // Intentionally undocumented he he he he
	Undocumented2   Undocumented2             `json:"Undocumented2"` // Intentionally undocumented he he he he
	Undocumented3   Undocumented3             `json:"Undocumented3"` // Intentionally undocumented he he he he
	Processor       *toolbox.CommandProcessor `json:"-"`             // Feature configuration
	ReplyMailClient inet.MailClient           `json:"-"`             // To deliver Email replies
	// contains filtered or unexported fields
}

CommandRunner looks for exactly one feature command from an incoming mail, runs it and reply the sender with command results. Usually used in combination of laitos' own SMTP daemon, but it can also work independently with another MTA such as the forwarding-mail-to-program mechanism from postfix.

func (*CommandRunner) Initialise

func (runner *CommandRunner) Initialise() error

Initialise initialises internal states of command runner. This function must be called before using the command runner.

func (*CommandRunner) Process

func (runner *CommandRunner) Process(clientIP string, mailContent []byte, replyAddresses ...string) error

Make sure mail processor is sane before processing the incoming mail. Process only one command (if found) in the incoming mail. If reply addresses are specified, send command result to the specified addresses. If they are not specified, use the incoming mail sender's address as reply address.

func (*CommandRunner) SelfTest

func (runner *CommandRunner) SelfTest() error

Run a health check on mailer and "undocumented" things.

type Undocumented1

type Undocumented1 struct {
	URL            string `json:"URL"`
	MailAddrSuffix string `json:"MailAddrSuffix"`
	ReplyAddress   string `json:"ReplyAddress"`
	MessageID      string `json:"MessageID"`
	GUID           string `json:"GUID"`
}

(GA - DE - IR) Intentionally undocumented he he he.

func (*Undocumented1) IsConfigured

func (und *Undocumented1) IsConfigured() bool

func (*Undocumented1) MayReplyTo

func (und *Undocumented1) MayReplyTo(prop inet.BasicMail) bool

func (*Undocumented1) SelfTest

func (und *Undocumented1) SelfTest() error

func (*Undocumented1) SendMessage

func (und *Undocumented1) SendMessage(message string) error

type Undocumented2

type Undocumented2 struct {
	URL            string `json:"URL"`
	MailAddrSuffix string `json:"MailAddrSuffix"`
	MsisDN         string `json:"MsisDN"`
	From           string `json:"From"`
}

(TH) Intentionally undocumented he he he.

func (*Undocumented2) IsConfigured

func (und *Undocumented2) IsConfigured() bool

func (*Undocumented2) MayReplyTo

func (und *Undocumented2) MayReplyTo(prop inet.BasicMail) bool

func (*Undocumented2) SelfTest

func (und *Undocumented2) SelfTest() error

func (*Undocumented2) SendMessage

func (und *Undocumented2) SendMessage(message string) error

type Undocumented3

type Undocumented3 struct {
	MailAddrSuffix string          `json:"MailAddrSuffix"`
	MailClient     inet.MailClient `json:"-"`
	Logger         *lalog.Logger   `json:"-"`
}

(IM) Intentionally undocumented he he he.

func (*Undocumented3) IsConfigured

func (und *Undocumented3) IsConfigured() bool

func (*Undocumented3) MayReplyTo

func (und *Undocumented3) MayReplyTo(prop inet.BasicMail) bool

func (*Undocumented3) SelfTest

func (und *Undocumented3) SelfTest() error

func (*Undocumented3) SendMessage

func (und *Undocumented3) SendMessage(prop inet.BasicMail, message string) error

Jump to

Keyboard shortcuts

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