Skip to main content

README.md

# sendr_lettermint

A [sendr](https://hex.pm/packages/sendr) backend for sending emails via the [Lettermint](https://lettermint.co) REST API.

## Installation

```sh
gleam add sendr sendr_lettermint
```

## Usage

```gleam
import gleam/http
import sendr
import sendr/message
import sendr/message/body
import sendr/message/mailbox
import sendr_lettermint

pub fn send() {
  let cfg = sendr_lettermint.config("lm-token-here")

  let msg =
    message.new()
    |> message.set_from(mailbox.new("Alice", "alice@example.com"))
    |> message.set_to([mailbox.new("Bob", "bob@example.com")])
    |> message.set_subject("Hello from sendr_lettermint")
    |> message.set_body(body.new() |> body.set_text("Hello world!"))

  let assert Ok(req) = sendr_lettermint.request(msg, cfg)

  // Make the HTTP request with your HTTP client of choice:
  // let resp = http_client.send(req)
  // let result = sendr_lettermint.response(resp)
}
```

## Configuration

```gleam
let cfg =
  sendr_lettermint.config("lm-token-here")
  |> sendr_lettermint.set_route("my-route")
```

## Shortcomings / Restrictions

- Lettermint doesn't support the reply-to header, an `Error` is returned if one is given.

## Development

```sh
gleam test                                   # Run the tests
LETTERMINT_TOKEN=your_token_here gleam test  # Run integration tests and unit tests
gleam run -m devutils/glinter -- --stats     # Run the code style checks
```