smtp

package module
v0.0.0-...-d5029a3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

lazuli-plugin-smtp

Lazuli @plugin/smtp adapter — production SMTP email delivery via github.com/wneessen/go-mail. Replaces the stdlib net/smtp wire shipped in-tree at runtime/go/lazuli/email/smtp.go, which can't produce RFC-compliant multipart/alternative HTML email.

Status

  • Go server adapter — wraps wneessen/go-mail v0.6+ for the in-plugin EmailSender contract (SendEmail, SendEmailBatch). Self-registers via init() against @plugin/smtp.
  • Hoists to notifications.EmailSender once that framework slot lands (see hostpoint-complete-roadmap-2026-05-18.md §2.3 + §3 caveat).

Usage

In Lazurite.toml:

[plugins]
"@plugin/smtp" = { module = "github.com/lazuli-lang/lazuli-plugin-smtp", version = "v0.1.0" }

Set env vars at runtime:

SMTP_HOST=smtp.example.com
SMTP_PORT=587                                # 587 = STARTTLS, 465 = TLS, 25 = plain
SMTP_USERNAME=apikey                         # provider-specific
SMTP_PASSWORD=...
SMTP_TLS_MODE=opportunistic                  # none|opportunistic|mandatory; default opportunistic
SMTP_FROM_DEFAULT=noreply@example.com        # fallback when EmailMessage.From is empty

In Go (handler code, until the framework notifications.EmailSender binding lands):

sender, err := lazuli.ResolveTyped[smtp.EmailSender]("@plugin/smtp")
if err != nil { return err }
return sender.SendEmail(ctx, smtp.EmailMessage{
    From:     "billing@hostpoint.app",
    To:       []string{user.Email},
    Subject:  "Your booking is confirmed",
    TextBody: "Plain-text version.",
    HTMLBody: "<html><body><strong>HTML</strong> version.</body></html>",
    Headers:  map[string]string{"X-Booking-ID": booking.ID},
})

What it does

  • SendEmail — single message. Multipart text/plain + text/html alternative when both bodies are set; single-part otherwise. Custom Headers are added as general headers.
  • SendEmailBatch — dials once, sends N on one connection (for digest delivery). Returns per-message errors plus a connection-level error.

Wire-thin discipline

~170 LOC total split across adapter.go (public surface, 88 LOC) and client.go (env parsing + message construction + client factory, 81 LOC). NO retry, NO circuit-breaker, NO template engine — those live upstream. The plugin only translates Lazuli's in-plugin EmailMessage to go-mail's *Msg.

Development

go mod tidy
go vet ./...
go test ./...

# integration smoke against MailHog
docker-compose up -d
INTEGRATION=1 go test -run TestSmoke ./...
docker-compose down

MailHog runs on port 1025 (SMTP) + 8025 (HTTP UI + API at http://localhost:8025).

License

MIT — see LICENSE.

Documentation

Overview

Package smtp is the Lazuli @plugin/smtp adapter — wire-thin wrapper around github.com/wneessen/go-mail for RFC-compliant MIME multipart email (HTML+text alternative, STARTTLS, OAuth2 SMTP).

Index

Constants

View Source
const AdapterRef = "@plugin/smtp"

Variables

View Source
var ErrUnconfigured = errors.New("smtp: SMTP_HOST not set")

Functions

This section is empty.

Types

type Adapter

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

func (*Adapter) SendEmail

func (a *Adapter) SendEmail(ctx context.Context, em EmailMessage) error

func (*Adapter) SendEmailBatch

func (a *Adapter) SendEmailBatch(ctx context.Context, ems []EmailMessage) ([]error, error)

SendEmailBatch dials once and sends N messages on one connection. Per-message errors share the input length; the second return is non-nil only when the dial/auth itself failed.

type EmailMessage

type EmailMessage struct {
	From, Subject, HTMLBody, TextBody string
	To                                []string
	Headers                           map[string]string
}

EmailMessage is the in-plugin contract; hoists to notifications.EmailSender when the framework slot lands.

type EmailSender

type EmailSender interface {
	SendEmail(ctx context.Context, msg EmailMessage) error
	SendEmailBatch(ctx context.Context, msgs []EmailMessage) ([]error, error)
}

Jump to

Keyboard shortcuts

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