Documentation
¶
Overview ¶
Package postal is the adapter for a self-hosted Postal server (postalserver.io). Webhooks are configured in Postal's web interface and signed with the server's RSA key (X-Postal-Signature-256, RS256 over the body), whose public half Postal publishes at /.well-known/jwks.json.
Postal has no API for domains, suppression lists or webhook management: ReputeCast enforces the shared suppression list before handing mail to Postal, and DNS records are set up by hand.
Index ¶
- Constants
- func Descriptor() providers.Descriptor
- func FetchJWKS(ctx context.Context, hc *http.Client, server string) (map[string]*rsa.PublicKey, error)
- func New(cfg providers.Config) (providers.Provider, error)
- func ParseJWKS(raw []byte) (map[string]*rsa.PublicKey, error)
- func ParsePublicKey(s string) (*rsa.PublicKey, error)
- type Credentials
- type Provider
- func (p *Provider) Adapter() string
- func (p *Provider) Backfill(ctx context.Context, ids []string) ([]providers.Event, error)
- func (p *Provider) Capabilities() providers.Capabilities
- func (p *Provider) ParseWebhook(ctx context.Context, r *http.Request, body []byte) ([]providers.Event, error)
- func (p *Provider) Send(ctx context.Context, msgs []providers.Message) ([]providers.SendResult, error)
- func (p *Provider) SendWithExtras(ctx context.Context, msgs []providers.Message, ...) ([]providers.SendResult, error)
- func (p *Provider) Verify(ctx context.Context) (providers.Quota, error)
- func (p *Provider) VerifyWebhook(ctx context.Context, r *http.Request, body []byte) error
- type Settings
Constants ¶
const Adapter = "postal"
Adapter is the registry key.
const TagPrefix = "rc:"
TagPrefix marks the X-Postal-Tag that carries the ReputeCast message id.
Variables ¶
This section is empty.
Functions ¶
func Descriptor ¶
func Descriptor() providers.Descriptor
Descriptor describes the adapter for the catalog.
func FetchJWKS ¶
func FetchJWKS(ctx context.Context, hc *http.Client, server string) (map[string]*rsa.PublicKey, error)
FetchJWKS downloads a Postal server's webhook signing keys.
Types ¶
type Credentials ¶
type Credentials struct {
APIKey string `json:"api_key"`
}
Credentials are write-only.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider talks to one Postal mail server.
func (*Provider) Backfill ¶
Backfill implements providers.EventBackfiller with /api/v1/messages/deliveries: the latest delivery of each message.
func (*Provider) Capabilities ¶
func (p *Provider) Capabilities() providers.Capabilities
Capabilities implements providers.Provider.
func (*Provider) ParseWebhook ¶
func (p *Provider) ParseWebhook(ctx context.Context, r *http.Request, body []byte) ([]providers.Event, error)
ParseWebhook implements providers.Provider.
func (*Provider) Send ¶
func (p *Provider) Send(ctx context.Context, msgs []providers.Message) ([]providers.SendResult, error)
Send implements providers.Provider through POST /api/v1/send/raw, one message per call (Postal has no batch endpoint).
func (*Provider) SendWithExtras ¶
func (p *Provider) SendWithExtras(ctx context.Context, msgs []providers.Message, extras []providers.MessageExtras) ([]providers.SendResult, error)
SendWithExtras implements providers.ExtrasSender: copies and attachments go in the raw message, every recipient in rcpt_to.
type Settings ¶
type Settings struct {
ServerURL string `json:"server_url"`
// SigningJWKS is Postal's webhook signing key set, fetched from
// /.well-known/jwks.json when the provider is connected.
SigningJWKS json.RawMessage `json:"signing_jwks,omitempty"`
// SigningKey is a PEM or base64 DER public key for Postal versions that
// show the key instead of publishing a JWKS.
SigningKey string `json:"signing_key,omitempty"`
Version string `json:"version,omitempty"`
}
Settings are the non-secret connection settings.