cloud

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cloud is the Mailtrap Sandbox Send API client.

Forwards a stored Message to the connected cloud sandbox at https://sandbox.api.mailtrap.io/api/send/{sandbox_id}. Same payload shape Mailtrap's hosted SDKs emit, with a reserved-headers list that matches the Send API's accepted set, and a transient/permanent error taxonomy so the dispatcher knows when to retry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIToken  string
	SandboxID int64
	BaseURL   string
	HTTP      *http.Client
}

Client targets a specific sandbox via API token. One Client per connected sandbox; built fresh each call site since auth is cheap.

BaseURL defaults to the production sandbox endpoint when zero. Tests override it by pointing at an httptest.Server; future staging-env support could use it the same way.

func NewClient

func NewClient(apiToken string, sandboxID int64) *Client

NewClient with a sane 15s timeout.

func (*Client) Send

func (c *Client) Send(ctx context.Context, m *store.Message, inline, attachments []store.Part) error

Send forwards a Message + its attachments to the connected sandbox. Returns nil on 2xx, ErrPermanent for 4xx (don't retry), or a generic error for 5xx / network blips (do retry).

type PermanentError

type PermanentError struct{ Msg string }

PermanentError signals "don't retry" (bad token, malformed payload, disabled sandbox).

func (*PermanentError) Error

func (e *PermanentError) Error() string

Jump to

Keyboard shortcuts

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