smtp

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(rt *runner.Runtime, sender Sender)

Register binds mail() to sender. The standard library itself is registered separately by the embedding host (stdlib.Register).

func RegisterSMTP added in v0.2.4

func RegisterSMTP(rt *runner.Runtime)

RegisterSMTP installs the SMTP class binding, so `new SMTP` in a script constructs a script-configured sender.

func SenderContext added in v0.2.4

func SenderContext(ctx context.Context, sender Sender) context.Context

SenderContext binds a Sender into the context. A runtime running with that context constructs `new SMTP` clients that hand their messages to the sender rather than dialing the configured host, which is how a host captures mail (see Memory) without a mail server.

Types

type Config

type Config struct {
	Host     string `yaml:"host" json:"host"`
	Port     int    `yaml:"port" json:"port"`
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
	From     string `yaml:"from" json:"from"`
}

Config contains the connection and sender settings for SMTP.

type Memory added in v0.2.4

type Memory struct {
	// contains filtered or unexported fields
}

Memory is a Sender that appends messages to an in-memory queue instead of delivering them. Hosts bind one with SenderContext to capture what scripts send (tests, local runs, dry runs).

func NewMemory added in v0.2.4

func NewMemory() *Memory

NewMemory creates an empty in-memory sender.

func (*Memory) Messages added in v0.2.4

func (m *Memory) Messages() []Message

Messages returns the queued messages in send order.

func (*Memory) Next added in v0.2.4

func (m *Memory) Next() (Message, bool)

Next pops the oldest queued message, reporting whether one was queued.

func (*Memory) Reset added in v0.2.4

func (m *Memory) Reset()

Reset empties the queue.

func (*Memory) Send added in v0.2.4

func (m *Memory) Send(recipient, subject, body string) error

Send queues a message.

type Message added in v0.2.4

type Message struct {
	Recipient string
	Subject   string
	Body      string
}

Message is a queued email.

type SMTP

type SMTP struct {
	// contains filtered or unexported fields
}

SMTP implements the Sender interface using SMTP

func NewSMTP

func NewSMTP(config Config) *SMTP

NewSMTP creates a new SMTP client

func NewSMTPBinding added in v0.2.4

func NewSMTPBinding(ctx context.Context, options *model.Array) (*SMTP, error)

NewSMTPBinding is the constructor callback registered for SMTP. It takes the connection settings as an associative array:

$smtp = new SMTP(array(
	"host"     => "mail.example.com",
	"port"     => 587,
	"username" => "noreply@example.com",
	"password" => "secret",
	"from"     => "Example <noreply@example.com>",
));

func (*SMTP) Send

func (s *SMTP) Send(recipient, subject, body string) error

Send sends an email via SMTP

type Sender

type Sender interface {
	Send(recipient, subject, body string) error
}

Sender interface defines methods for sending emails

Jump to

Keyboard shortcuts

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