Documentation
¶
Overview ¶
Package email provides a Starlark module that sends email through the Resend API (https://resend.com). It is an L4 starpkg domain module: a thin, simple abstraction over a common online service, with one local touch point (reading host files for attachments).
The module exposes a single additional builtin, send(), alongside the config setters/getters generated by the underlying configurable module (set_resend_api_key, set_sender_domain, get_sender_domain). send() returns a starlarkstruct with the following fields describing the outcome:
- success: bool, whether the email was sent successfully
- error: error message if sending failed, else None
- id: the unique identifier of the sent email, else None
- sender: the resolved sender address (from field), else None
- to: list of recipient addresses, else None
- cc: list of CC recipient addresses, else None
- bcc: list of BCC recipient addresses, else None
- reply_to: the reply-to address, else None
- subject: the email subject, else None
- body_html: the HTML content of the email, else None
- body_text: the plain text content of the email, else None
- attachments: list of attachment dicts (name, content), else None
A transport failure (the Resend call returning an error) yields a struct with success False, error set to the message, and every echoed field None except attachments, which still reflects any attachments that were supplied (None when none were). Earlier failures — a missing API key, validation errors, or an unreadable attachment file — surface as a Starlark error rather than a result struct.
Index ¶
Constants ¶
const ModuleName = "email"
ModuleName defines the expected name for this module when used in Starlark's load() function, e.g., load('email', 'send')
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module wraps the ConfigurableModule with specific functionality for sending emails.
func NewModule ¶
func NewModule() *Module
NewModule creates a new instance of Module with default empty configurations.
func NewModuleWithConfig ¶
NewModuleWithConfig creates a new instance of Module with the given configuration values.
func (*Module) LoadModule ¶
func (m *Module) LoadModule() starlet.ModuleLoader
LoadModule returns the Starlark module loader with the email-specific functions.