letmesendemail

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 17 Imported by: 0

README

letmesend.email Go SDK

The official Go 1.22+ SDK for the letmesend.email API.

Installation

go get github.com/letmesendemail/letmesendemail-go

Quick Start

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/letmesendemail/letmesendemail-go"
)

func main() {
    apiKey := os.Getenv("LETMESENDEMAIL_API_KEY")
    if apiKey == "" {
        log.Fatal("LETMESENDEMAIL_API_KEY is required")
    }

    client, err := letmesendemail.New(apiKey)
    if err != nil {
        log.Fatal(err)
    }

    html := "<p>Welcome!</p>"
    email, err := client.Emails.Send(context.Background(), &letmesendemail.SendEmailRequest{
        From:    "Acme <hello@example.test>",
        To:      []string{"person@example.test"},
        Subject: "Welcome",
        HTML:    &html,
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(email.ID, email.Status)
}

Configuration

client, err := letmesendemail.New(
    apiKey,
    letmesendemail.WithBaseURL("https://letmesend.email/api/v1"),
    letmesendemail.WithTimeout(30_000),
    letmesendemail.WithRetries(3),
    letmesendemail.WithHTTPClient(customHTTPClient),
)
Option Default Behavior
WithBaseURL https://letmesend.email/api/v1 Absolute HTTP(S) URL without credentials, query, or fragment
WithTimeout 30000 ms Per-attempt timeout, including response-body reading, for default and injected clients
WithRetries 0 Retries after the initial attempt; normalized to the range 0–20
WithHTTPClient SDK client Injects a custom *http.Client or transport

New validates configuration and returns an error. MustNew is available for startup code where invalid configuration should panic. The SDK sends letmesendemail-go/<module-version> as its User-Agent.

Emails

email, err := client.Emails.Send(ctx, &letmesendemail.SendEmailRequest{
    From:           "Acme <hello@example.test>",
    To:             []string{"person@example.test"},
    Subject:        "Hello",
    Text:           stringPtr("Hello"),
    IdempotencyKey: "unique-operation-key",
})

templated, err := client.Emails.SendWithTemplate(ctx, &letmesendemail.SendWithTemplateRequest{
    From:       "Acme <hello@example.test>",
    To:         []string{"person@example.test"},
    TemplateID: "template_123",
    TemplateVariables: []letmesendemail.TemplateVariable{
        {Key: "name", Type: "string", Value: "Taylor"},
        {Key: "items", Type: "number", Value: 2},
    },
})

verification, err := client.Emails.Verify(ctx, "person@example.test")
page, err := client.Emails.List(ctx, intPtr(20), nil, nil)
detail, err := client.Emails.Get(ctx, "email_123")

Attachments support Name, Path, Base64 Content, Mime, ContentID, and ContentDisposition. Path and Content are mutually exclusive.

Domains

page, err := client.Domains.List(ctx, intPtr(20), nil, nil)
domain, err := client.Domains.Get(ctx, "domain_123")
verification, err := client.Domains.Verify(ctx, "example.test")

Contacts

contact, err := client.Contacts.Create(ctx, &letmesendemail.CreateContactRequest{Email: "person@example.test"})
page, err := client.Contacts.List(ctx, intPtr(20), nil, nil)
contact, err = client.Contacts.Get(ctx, "contact_123")
updated, err := client.Contacts.Update(ctx, "contact_123", &letmesendemail.UpdateContactRequest{FirstName: stringPtr("Taylor")})
deleted, err := client.Contacts.Delete(ctx, "contact_123")

Contact Categories

category, err := client.ContactCategories.Create(ctx, "Customers", nil)
page, err := client.ContactCategories.List(ctx, intPtr(20), nil, nil)
category, err = client.ContactCategories.Get(ctx, "category_123")
category, err = client.ContactCategories.Update(ctx, "category_123", "Active Customers", nil)
deleted, err := client.ContactCategories.Delete(ctx, "category_123")

Email Topics

topic, err := client.EmailTopics.Create(ctx, &letmesendemail.CreateEmailTopicRequest{Name: "Product updates", Slug: "product-updates"})
page, err := client.EmailTopics.List(ctx, intPtr(20), nil, nil)
topic, err = client.EmailTopics.Get(ctx, "topic_123")
topic, err = client.EmailTopics.Update(ctx, "topic_123", &letmesendemail.UpdateEmailTopicRequest{Name: stringPtr("News")})
deleted, err := client.EmailTopics.Delete(ctx, "topic_123")

The snippets above show call shapes; production code must check each returned error before using its result. The full manual contains complete programs and field coverage.

Pagination

All list resources use the same cursor arguments:

page, err := client.Emails.List(ctx, intPtr(20), nil, nil)
if err != nil {
    return err
}
if page.Pagination.HasMore && len(page.Data) > 0 {
    after := page.Data[len(page.Data)-1].ID
    next, err := client.Emails.List(ctx, intPtr(20), &after, nil)
    if err != nil {
        return err
    }
    _ = next
}
if len(page.Data) > 0 {
    before := page.Data[0].ID
    previous, err := client.Emails.List(ctx, intPtr(20), nil, &before)
    if err != nil {
        return err
    }
    _ = previous
}

Never provide after and before together. Retain cursor history when building Back navigation because the API does not return has_previous.

Model Serialization

Public models are exported structs with stable snake_case JSON tags, so encoding/json is the native serialization path. Models also provide ToMap() (map[string]interface{}, error) for database-record preparation:

record, err := detail.ToMap()
if err != nil {
    return err
}
encoded, err := json.Marshal(record)

Conversion recursively copies nested values. Request-only header values such as IdempotencyKey, credentials, clients, and transports are excluded.

Error Handling

_, err := client.Emails.Get(ctx, "email_123")
if err != nil {
    var validation *letmesendemail.ValidationError
    var limited *letmesendemail.RateLimitError
    var timeout *letmesendemail.TimeoutError
    var network *letmesendemail.NetworkError

    switch {
    case errors.As(err, &validation):
        fmt.Println(validation.ValidationErrors)
    case errors.As(err, &limited):
        fmt.Println(limited.RetryAfter)
    case errors.As(err, &timeout):
        fmt.Println("SDK timeout")
    case errors.As(err, &network):
        fmt.Println("network failure")
    case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
        fmt.Println("caller canceled the operation")
    default:
        fmt.Println(err)
    }
}

Structured types include authentication, authorization, validation, not-found, conflict, rate-limit, API, network, timeout, serialization, and webhook errors. errors.As can also extract *LetMeSendEmailError for common metadata.

Retries

Retries cover network failures, SDK timeouts, HTTP 408/500/502/503/504, and HTTP 429 with a valid Retry-After of 1–300 seconds. GET, HEAD, OPTIONS, and DELETE are eligible. POST, PUT, and PATCH require an idempotency key. Email and domain verification are not retried. Caller cancellation and caller deadlines are preserved and never retried.

Exponential delay begins at 100 ms, adds random jitter below 25%, and caps at 300 seconds. A valid rate-limit delay is used exactly without jitter.

Webhooks

payload, err := io.ReadAll(r.Body)
if err != nil {
    http.Error(w, "Unable to read request", http.StatusBadRequest)
    return
}
secret := os.Getenv("LETMESENDEMAIL_WEBHOOK_SECRET")
if secret == "" {
    http.Error(w, "Webhook verification unavailable", http.StatusInternalServerError)
    return
}
verified, err := webhooks.Verify(string(payload), r.Header, secret)
if err != nil {
    log.Printf("webhook verification failed: %v", err)
    http.Error(w, "Invalid webhook signature", http.StatusUnauthorized)
    return
}
fmt.Printf("verified payload: %#v\n", verified)

Verification uses the unmodified body and the webhook-id, webhook-log-id, webhook-timestamp, and webhook-signature headers. No event payload schema is assumed.

Testing

gofmt -l .
go mod verify
go vet ./...
go test ./... -count=1
go test -race ./... -count=1
go build ./...

Version Support

Go 1.22 and later are supported. CI tests the minimum version and maintained/current Go releases.

Changelog

See CHANGELOG.md.

Full Documentation

Read the complete Go SDK user manual.

func stringPtr(value string) *string { return &value }
func intPtr(value int) *int          { return &value }

Documentation

Overview

Package letmesendemail provides an idiomatic Go client for the letmesend.email API.

Index

Constants

View Source
const (
	// DefaultBaseURL is the production API endpoint used by new clients.
	DefaultBaseURL = "https://letmesend.email/api/v1"
	// DefaultTimeoutMs is the per-attempt timeout in milliseconds.
	DefaultTimeoutMs = 30_000
	// DefaultRetries disables automatic retries unless explicitly configured.
	DefaultRetries = 0
	// MaxRetryDelay is the maximum retry delay in seconds.
	MaxRetryDelay = 300
	// MaxRetries is the maximum accepted retry count.
	MaxRetries = 20
)

Variables

This section is empty.

Functions

func ModelToMap

func ModelToMap(v interface{}) (map[string]interface{}, error)

ModelToMap converts any JSON-serializable SDK model into independent plain data.

func Version

func Version() string

Version returns the SDK module version embedded by the Go toolchain, or "devel" when no released module version is available.

Types

type ApiError

type ApiError struct{ LetMeSendEmailError }

ApiError represents a generic API error (5xx or otherwise unclassified).

func (*ApiError) Unwrap

func (e *ApiError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type AuthenticationError

type AuthenticationError struct{ LetMeSendEmailError }

AuthenticationError represents a 401 response.

func (*AuthenticationError) Unwrap

func (e *AuthenticationError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type AuthorizationError

type AuthorizationError struct{ LetMeSendEmailError }

AuthorizationError represents a 403 response.

func (*AuthorizationError) Unwrap

func (e *AuthorizationError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type Config

type Config struct {
	// APIKey is the bearer token used for API authentication.
	APIKey string
	// BaseURL overrides the API endpoint. It must be an absolute HTTP(S) URL.
	BaseURL string
	// TimeoutMs is the per-attempt timeout in milliseconds.
	TimeoutMs int
	// Retries is the maximum number of retries after the initial attempt.
	Retries int
	// HTTPClient optionally supplies a custom HTTP transport.
	HTTPClient *http.Client
}

Config controls client authentication, transport, timeout, and retry behavior.

func NewConfig

func NewConfig(apiKey string) Config

NewConfig returns a Config populated with production defaults.

func (*Config) Validate

func (c *Config) Validate() error

Validate normalizes defaults and rejects unsafe or invalid configuration.

type ConflictError

type ConflictError struct{ LetMeSendEmailError }

ConflictError represents a 409 response.

func (*ConflictError) Unwrap

func (e *ConflictError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type ContactCategoriesResource

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

ContactCategoriesResource provides contact-category operations.

func (*ContactCategoriesResource) Create

Create creates a contact category.

func (*ContactCategoriesResource) Delete

Delete deletes one contact category.

func (*ContactCategoriesResource) Get

Get retrieves one contact category.

func (*ContactCategoriesResource) List

func (r *ContactCategoriesResource) List(ctx context.Context, perPage *int, after, before *string) (*ContactCategoryListResponse, error)

List returns one cursor-paginated page of contact categories.

func (*ContactCategoriesResource) Update

func (r *ContactCategoriesResource) Update(ctx context.Context, id, name string, slug *string) (*ContactCategoryItem, error)

Update updates one contact category.

type ContactCategoryItem

type ContactCategoryItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

ContactCategoryItem represents a contact category.

func (*ContactCategoryItem) ToMap

func (c *ContactCategoryItem) ToMap() (map[string]interface{}, error)

ToMap returns the category as a map[string]interface{}.

type ContactCategoryListResponse

type ContactCategoryListResponse struct {
	Data       []ContactCategoryItem `json:"data"`
	Pagination PaginationInfo        `json:"pagination"`
}

ContactCategoryListResponse is the paginated list response for contact categories.

func (*ContactCategoryListResponse) ToMap

func (c *ContactCategoryListResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type ContactItem

type ContactItem struct {
	ID                     string                `json:"id"`
	Email                  string                `json:"email"`
	FirstName              *string               `json:"first_name"`
	LastName               *string               `json:"last_name"`
	Phone                  *string               `json:"phone"`
	IsGloballyUnsubscribed bool                  `json:"is_globally_unsubscribed"`
	CreatedAt              string                `json:"created_at"`
	Categories             []ContactCategoryItem `json:"categories,omitempty"`
}

ContactItem represents a contact returned by the API.

func (*ContactItem) ToMap

func (c *ContactItem) ToMap() (map[string]interface{}, error)

ToMap returns the contact as a map[string]interface{}.

type ContactListResponse

type ContactListResponse struct {
	Data       []ContactItem  `json:"data"`
	Pagination PaginationInfo `json:"pagination"`
}

ContactListResponse is the paginated list response for contacts.

func (*ContactListResponse) ToMap

func (c *ContactListResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type ContactUpdateResponse

type ContactUpdateResponse struct {
	ID string `json:"id"`
}

ContactUpdateResponse is the response from updating a contact.

func (*ContactUpdateResponse) ToMap

func (c *ContactUpdateResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type ContactsResource

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

ContactsResource provides contact operations.

func (*ContactsResource) Create

Create creates a contact.

func (*ContactsResource) Delete

func (r *ContactsResource) Delete(ctx context.Context, id string) (*StatusResponse, error)

Delete deletes one contact.

func (*ContactsResource) Get

Get retrieves one contact.

func (*ContactsResource) List

func (r *ContactsResource) List(ctx context.Context, perPage *int, after, before *string) (*ContactListResponse, error)

List returns one cursor-paginated page of contacts.

func (*ContactsResource) Update

Update updates one contact.

type CreateContactRequest

type CreateContactRequest struct {
	Email                  string   `json:"email"`
	FirstName              *string  `json:"first_name,omitempty"`
	LastName               *string  `json:"last_name,omitempty"`
	Phone                  *string  `json:"phone,omitempty"`
	IsGloballyUnsubscribed *bool    `json:"is_globally_unsubscribed,omitempty"`
	Categories             []string `json:"categories,omitempty"`
	EmailTopics            []string `json:"email_topics,omitempty"`
}

CreateContactRequest is the request payload for creating a contact.

func (*CreateContactRequest) ToMap

func (c *CreateContactRequest) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible request representation.

type CreateEmailTopicRequest

type CreateEmailTopicRequest struct {
	Name          string               `json:"name"`
	Slug          string               `json:"slug"`
	AutoSubscribe *bool                `json:"auto_subscribe,omitempty"`
	Public        *bool                `json:"public,omitempty"`
	Description   *string              `json:"description,omitempty"`
	Domain        *EmailTopicDomainRef `json:"domain,omitempty"`
}

CreateEmailTopicRequest is the request payload for creating an email topic.

func (*CreateEmailTopicRequest) ToMap

func (c *CreateEmailTopicRequest) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible request representation.

type DomainItem

type DomainItem struct {
	ID         string `json:"id"`
	DomainName string `json:"domain_name"`
	Status     string `json:"status"`
	CreatedAt  string `json:"created_at"`
}

DomainItem represents a sending domain.

func (*DomainItem) ToMap

func (d *DomainItem) ToMap() (map[string]interface{}, error)

ToMap returns the domain as a map[string]interface{}.

type DomainListResponse

type DomainListResponse struct {
	Data       []DomainItem   `json:"data"`
	Pagination PaginationInfo `json:"pagination"`
}

DomainListResponse is the paginated list response for domains.

func (*DomainListResponse) ToMap

func (d *DomainListResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type DomainsResource

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

DomainsResource provides sending-domain operations.

func (*DomainsResource) Get

func (r *DomainsResource) Get(ctx context.Context, id string) (*DomainItem, error)

Get retrieves one sending domain.

func (*DomainsResource) List

func (r *DomainsResource) List(ctx context.Context, perPage *int, after, before *string) (*DomainListResponse, error)

List returns one cursor-paginated page of domains.

func (*DomainsResource) Verify

func (r *DomainsResource) Verify(ctx context.Context, domain string) (*StatusResponse, error)

Verify requests verification of a sending domain.

type EmailAttachment

type EmailAttachment struct {
	ID                 string `json:"id"`
	Name               string `json:"name"`
	Mime               string `json:"mime"`
	ContentID          string `json:"content_id"`
	ContentDisposition string `json:"content_disposition"`
	Size               int    `json:"size"`
	DownloadURL        string `json:"download_url"`
}

EmailAttachment contains details about an email attachment.

func (*EmailAttachment) ToMap

func (a *EmailAttachment) ToMap() (map[string]interface{}, error)

ToMap returns the attachment as a map[string]interface{}.

type EmailListItem

type EmailListItem struct {
	ID               string  `json:"id"`
	Status           string  `json:"status"`
	Subject          *string `json:"subject"`
	EventName        *string `json:"event_name"`
	Type             string  `json:"type"`
	CreatedAt        string  `json:"created_at"`
	SentAt           *string `json:"sent_at"`
	RecipientsCount  int     `json:"recipients_count"`
	AttachmentsCount int     `json:"attachments_count"`
}

EmailListItem is a single item in the email list response.

func (*EmailListItem) ToMap

func (e *EmailListItem) ToMap() (map[string]interface{}, error)

ToMap returns the item as a map[string]interface{}.

type EmailListResponse

type EmailListResponse struct {
	Data       []EmailListItem `json:"data"`
	Pagination PaginationInfo  `json:"pagination"`
}

EmailListResponse is the paginated list response for emails.

func (*EmailListResponse) ToMap

func (e *EmailListResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type EmailTopicDomainRef

type EmailTopicDomainRef struct {
	ID   string  `json:"id"`
	Name *string `json:"name,omitempty"`
}

EmailTopicDomainRef represents a domain reference on email topics.

func (*EmailTopicDomainRef) ToMap

func (e *EmailTopicDomainRef) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible representation.

type EmailTopicItem

type EmailTopicItem struct {
	ID            string               `json:"id"`
	Name          string               `json:"name"`
	Slug          string               `json:"slug"`
	Description   *string              `json:"description"`
	AutoSubscribe bool                 `json:"auto_subscribe"`
	Public        bool                 `json:"public"`
	CreatedAt     string               `json:"created_at"`
	Domain        *EmailTopicDomainRef `json:"domain,omitempty"`
}

EmailTopicItem represents an email topic.

func (*EmailTopicItem) ToMap

func (e *EmailTopicItem) ToMap() (map[string]interface{}, error)

ToMap returns the topic as a map[string]interface{}.

type EmailTopicListResponse

type EmailTopicListResponse struct {
	Data       []EmailTopicItem `json:"data"`
	Pagination PaginationInfo   `json:"pagination"`
}

EmailTopicListResponse is the paginated list response for email topics.

func (*EmailTopicListResponse) ToMap

func (e *EmailTopicListResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type EmailTopicsResource

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

EmailTopicsResource provides email-topic operations.

func (*EmailTopicsResource) Create

Create creates an email topic.

func (*EmailTopicsResource) Delete

Delete deletes one email topic.

func (*EmailTopicsResource) Get

Get retrieves one email topic.

func (*EmailTopicsResource) List

func (r *EmailTopicsResource) List(ctx context.Context, perPage *int, after, before *string) (*EmailTopicListResponse, error)

List returns one cursor-paginated page of email topics.

func (*EmailTopicsResource) Update

Update updates one email topic.

type EmailsResource

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

EmailsResource provides email sending, verification, listing, and retrieval.

func (*EmailsResource) Get

Get retrieves detailed information for one email.

func (*EmailsResource) List

func (r *EmailsResource) List(ctx context.Context, perPage *int, after, before *string) (*EmailListResponse, error)

List returns one cursor-paginated page of emails.

func (*EmailsResource) Send

Send sends a regular email.

func (*EmailsResource) SendWithTemplate

func (r *EmailsResource) SendWithTemplate(ctx context.Context, req *SendWithTemplateRequest) (*SendEmailResponse, error)

SendWithTemplate sends an email rendered from a template.

func (*EmailsResource) Verify

func (r *EmailsResource) Verify(ctx context.Context, email string) (*VerifyEmailResponse, error)

Verify verifies an email address.

type LetMeSendEmail

type LetMeSendEmail struct {

	// Emails provides email sending, verification, listing, and retrieval.
	Emails *EmailsResource
	// Domains provides sending-domain operations.
	Domains *DomainsResource
	// Contacts provides contact operations.
	Contacts *ContactsResource
	// ContactCategories provides contact-category operations.
	ContactCategories *ContactCategoriesResource
	// EmailTopics provides email-topic operations.
	EmailTopics *EmailTopicsResource
	// contains filtered or unexported fields
}

LetMeSendEmail is the SDK client and exposes each supported API resource.

func MustNew

func MustNew(apiKey string, opts ...Option) *LetMeSendEmail

MustNew creates a new SDK client and panics if configuration is invalid.

func New

func New(apiKey string, opts ...Option) (*LetMeSendEmail, error)

New creates a new SDK client with the given API key and options. Returns an error if the configuration is invalid.

type LetMeSendEmailError

type LetMeSendEmailError struct {
	// Message describes the error.
	Message string
	// StatusCode is the HTTP status code, or 0 for client-side errors.
	StatusCode int
	// APICode is the API error code from the response body.
	APICode string
	// ValidationErrors maps field names to error messages for 422 responses.
	ValidationErrors map[string][]string
	// RequestID is the x-request-id header value.
	RequestID string
	// ResponseHeaders contains the HTTP response headers.
	ResponseHeaders map[string]string
	// RawBody is the raw response body string.
	RawBody string
}

LetMeSendEmailError is the base error type for all SDK errors.

func (*LetMeSendEmailError) Error

func (e *LetMeSendEmailError) Error() string

Error returns the error message.

type NetworkError

type NetworkError struct{ LetMeSendEmailError }

NetworkError represents a network-level error (connection refused, DNS failure, etc.).

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type NotFoundError

type NotFoundError struct{ LetMeSendEmailError }

NotFoundError represents a 404 response.

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type Option

type Option func(*Config)

Option customizes client configuration during construction.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the default API endpoint.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient injects a custom HTTP client while retaining SDK timeout handling.

func WithRetries

func WithRetries(retries int) Option

WithRetries sets the number of retries after the initial attempt.

func WithTimeout

func WithTimeout(timeoutMs int) Option

WithTimeout sets the per-attempt timeout in milliseconds.

type PaginationInfo

type PaginationInfo struct {
	HasMore bool `json:"has_more"`
	PerPage int  `json:"per_page"`
	Fetched int  `json:"fetched"`
	Total   int  `json:"total"`
}

PaginationInfo contains pagination metadata returned by list endpoints.

func (*PaginationInfo) ToMap

func (p *PaginationInfo) ToMap() (map[string]interface{}, error)

ToMap returns the pagination info as a map[string]interface{}.

type RateLimitError

type RateLimitError struct {
	LetMeSendEmailError
	// RetryAfter is the number of seconds to wait before retrying.
	RetryAfter int
	// Limit is the total rate limit allowance.
	Limit int
	// Remaining is the remaining rate limit allowance.
	Remaining int
	// ResetAt is the timestamp when the rate limit resets.
	ResetAt string
}

RateLimitError represents a 429 response.

func (*RateLimitError) Unwrap

func (e *RateLimitError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type Recipient

type Recipient struct {
	Type              string  `json:"type"`
	Status            string  `json:"status"`
	EmailAddress      string  `json:"email_address"`
	BounceType        *string `json:"bounce_type"`
	BounceReason      *string `json:"bounce_reason"`
	BouncedAt         *string `json:"bounced_at"`
	ComplaintType     *string `json:"complaint_type"`
	ComplainedAt      *string `json:"complained_at"`
	IsSuppressed      bool    `json:"is_suppressed"`
	SuppressionReason *string `json:"suppression_reason"`
	OpenedAt          *string `json:"opened_at"`
	OpenCount         int     `json:"open_count"`
	ClickedAt         *string `json:"clicked_at"`
	ClickCount        int     `json:"click_count"`
	FailedAt          *string `json:"failed_at"`
	ErrorMessage      *string `json:"error_message"`
	DeliveredAt       *string `json:"delivered_at"`
	SentAt            *string `json:"sent_at"`
}

Recipient contains details about an email recipient.

func (*Recipient) ToMap

func (r *Recipient) ToMap() (map[string]interface{}, error)

ToMap returns the recipient as a map[string]interface{}.

type SendAttachment

type SendAttachment struct {
	Name               string `json:"name,omitempty"`
	Path               string `json:"path,omitempty"`
	Content            string `json:"content,omitempty"`
	Mime               string `json:"mime,omitempty"`
	ContentID          string `json:"content_id,omitempty"`
	ContentDisposition string `json:"content_disposition,omitempty"`
}

SendAttachment represents a file attached to an email.

func (*SendAttachment) ToMap

func (s *SendAttachment) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible representation.

type SendEmailRequest

type SendEmailRequest struct {
	From           string            `json:"from"`
	To             []string          `json:"to"`
	Subject        string            `json:"subject"`
	HTML           *string           `json:"html,omitempty"`
	Text           *string           `json:"text,omitempty"`
	Type           *string           `json:"type,omitempty"`
	EventName      *string           `json:"event_name,omitempty"`
	EmailTopicID   *string           `json:"email_topic_id,omitempty"`
	ReplyTo        []string          `json:"reply_to,omitempty"`
	Cc             []string          `json:"cc,omitempty"`
	Bcc            []string          `json:"bcc,omitempty"`
	Headers        map[string]string `json:"headers,omitempty"`
	Attachments    []SendAttachment  `json:"attachments,omitempty"`
	IdempotencyKey string            `json:"-"`
}

SendEmailRequest is the request payload for sending an email.

func (*SendEmailRequest) ToMap

func (s *SendEmailRequest) ToMap() (map[string]interface{}, error)

ToMap returns the API request body without the idempotency header value.

type SendEmailResponse

type SendEmailResponse struct {
	ID               string   `json:"id"`
	Status           string   `json:"status"`
	Emails           []string `json:"emails"`
	RestrictedEmails []string `json:"restricted_emails"`
	Duplicate        bool     `json:"duplicate"`
}

SendEmailResponse is the response after sending an email.

func (*SendEmailResponse) ToMap

func (s *SendEmailResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type SendWithTemplateRequest

type SendWithTemplateRequest struct {
	From              string             `json:"from"`
	To                []string           `json:"to"`
	TemplateID        string             `json:"template_id"`
	Subject           *string            `json:"subject,omitempty"`
	TemplateVariables []TemplateVariable `json:"template_variables,omitempty"`
	Type              *string            `json:"type,omitempty"`
	EventName         *string            `json:"event_name,omitempty"`
	EmailTopicID      *string            `json:"email_topic_id,omitempty"`
	ReplyTo           []string           `json:"reply_to,omitempty"`
	Cc                []string           `json:"cc,omitempty"`
	Bcc               []string           `json:"bcc,omitempty"`
	Headers           map[string]string  `json:"headers,omitempty"`
	Attachments       []SendAttachment   `json:"attachments,omitempty"`
	IdempotencyKey    string             `json:"-"`
}

SendWithTemplateRequest is the request payload for sending a templated email.

func (*SendWithTemplateRequest) ToMap

func (s *SendWithTemplateRequest) ToMap() (map[string]interface{}, error)

ToMap returns the API request body without the idempotency header value.

type SerializationError

type SerializationError struct{ LetMeSendEmailError }

SerializationError represents a local request or model serialization failure.

func (*SerializationError) Unwrap

func (e *SerializationError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type ShowEmailResponse

type ShowEmailResponse struct {
	ID               string            `json:"id"`
	Status           string            `json:"status"`
	Subject          *string           `json:"subject"`
	EventName        *string           `json:"event_name"`
	Type             string            `json:"type"`
	CreatedAt        string            `json:"created_at"`
	SentAt           *string           `json:"sent_at"`
	RecipientsCount  int               `json:"recipients_count"`
	AttachmentsCount int               `json:"attachments_count"`
	Recipients       []Recipient       `json:"recipients"`
	Attachments      []EmailAttachment `json:"attachments"`
}

ShowEmailResponse is the detailed response for a single email, including recipients and attachments.

func (*ShowEmailResponse) ToMap

func (s *ShowEmailResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type StatusResponse

type StatusResponse struct {
	Status  string  `json:"status"`
	Message *string `json:"message,omitempty"`
}

StatusResponse is a generic status response returned by operations like domain verification.

func (*StatusResponse) ToMap

func (s *StatusResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type TemplateVariable

type TemplateVariable struct {
	Key   string      `json:"key"`
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

TemplateVariable represents a variable used in template-based emails.

func (*TemplateVariable) ToMap

func (t *TemplateVariable) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible representation.

type TimeoutError

type TimeoutError struct{ LetMeSendEmailError }

TimeoutError represents a request timeout.

func (*TimeoutError) Unwrap

func (e *TimeoutError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type UpdateContactRequest

type UpdateContactRequest struct {
	FirstName              *string  `json:"first_name,omitempty"`
	LastName               *string  `json:"last_name,omitempty"`
	Phone                  *string  `json:"phone,omitempty"`
	IsGloballyUnsubscribed *bool    `json:"is_globally_unsubscribed,omitempty"`
	Categories             []string `json:"categories,omitempty"`
	EmailTopics            []string `json:"email_topics,omitempty"`
	SyncCategories         *bool    `json:"sync_categories,omitempty"`
	SyncEmailTopics        *bool    `json:"sync_email_topics,omitempty"`
}

UpdateContactRequest is the request payload for updating a contact.

func (*UpdateContactRequest) ToMap

func (u *UpdateContactRequest) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible request representation.

type UpdateEmailTopicRequest

type UpdateEmailTopicRequest struct {
	Name          *string `json:"name,omitempty"`
	Slug          *string `json:"slug,omitempty"`
	Description   *string `json:"description,omitempty"`
	Public        *bool   `json:"public,omitempty"`
	AutoSubscribe *bool   `json:"auto_subscribe,omitempty"`
}

UpdateEmailTopicRequest is the request payload for updating an email topic.

func (*UpdateEmailTopicRequest) ToMap

func (u *UpdateEmailTopicRequest) ToMap() (map[string]interface{}, error)

ToMap returns an independent JSON-compatible request representation.

type ValidationError

type ValidationError struct{ LetMeSendEmailError }

ValidationError represents a 400, 413, or 422 response.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap exposes the common SDK error metadata.

type VerifyEmailResponse

type VerifyEmailResponse struct {
	Email        string  `json:"email"`
	Score        int     `json:"score"`
	Status       string  `json:"status"`
	DomainExists bool    `json:"domain_exists"`
	Disposable   bool    `json:"disposable"`
	RoleBased    bool    `json:"role_based"`
	HasMailbox   bool    `json:"has_mailbox"`
	ReceiveEmail bool    `json:"receive_email"`
	MXRecords    bool    `json:"mx_records"`
	ValidSyntax  bool    `json:"valid_syntax"`
	BelongsTo    *string `json:"belongs_to"`
}

VerifyEmailResponse is the response from email address verification.

func (*VerifyEmailResponse) ToMap

func (v *VerifyEmailResponse) ToMap() (map[string]interface{}, error)

ToMap returns the response as a map[string]interface{}.

type WebhookSigningError

type WebhookSigningError = webhooks.WebhookSigningError

WebhookSigningError is a compatibility alias for webhooks.WebhookSigningError.

type WebhookVerificationError

type WebhookVerificationError = webhooks.WebhookVerificationError

WebhookVerificationError is a compatibility alias for webhooks.WebhookVerificationError.

Directories

Path Synopsis
examples
attachments command
errors command
idempotency command
pagination command
send command
template command
webhooks command
Package webhooks provides webhook signature verification for letmesend.email.
Package webhooks provides webhook signature verification for letmesend.email.

Jump to

Keyboard shortcuts

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