# modules/mail/resend

```go
import "apistock.dev/modules/mail/resend"
```

Package resend sends email with Resend ([https://resend.com](https://resend.com)) through its HTTP API (ADR-0025, ADR-0037).

	sender, err := resend.New(cfg.ResendAPIKey)

The API key is a secret from the environment (RESEND\_API\_KEY). Sender names and addresses are chosen per message; apps fill them from runtime settings with mail.WithDefaults.

Refusals that retrying can't fix (invalid messages, unverified sender domains) wrap [mail.ErrRejected](/reference/mail/#ErrRejected). Rate limits, outages and an invalid API key (fixable by an operator) are temporary. Each message's idempotency key is sent as Resend's Idempotency-Key, so a retried job never sends twice.

Stability: pre-1.0 (ADR-0015).

## Constants

### const DefaultBaseURL, …

```go
const (
	DefaultBaseURL = "https://api.resend.com"
	DefaultTimeout = 30 * time.Second
)
```

Defaults.

## Types

### type Option

```go
type Option interface {
	// contains filtered or unexported methods
}
```

An Option configures [New](#New).

#### func WithBaseURL

```go
func WithBaseURL(u string) Option
```

WithBaseURL sets the API base URL, for tests. Default: [DefaultBaseURL](#DefaultBaseURL).

#### func WithHTTPClient

```go
func WithHTTPClient(c *http.Client) Option
```

WithHTTPClient sets the HTTP client, for example one with a proxy. Its own timeout applies instead of [WithTimeout](#WithTimeout).

#### func WithTimeout

```go
func WithTimeout(d time.Duration) Option
```

WithTimeout bounds each API request. Default: [DefaultTimeout](#DefaultTimeout).

### type Sender

```go
type Sender struct {
	// contains filtered or unexported fields
}
```

Sender delivers email through the Resend API. It is safe for concurrent use.

#### func New

```go
func New(apiKey config.Secret, opts ...Option) (*Sender, error)
```

New returns a sender using apiKey, a Resend API key such as "re\_123…".

#### func (*Sender) Send

```go
func (s *Sender) Send(ctx context.Context, m mail.Message) error
```

Send delivers m.

