1# gleesend
2
3[](https://hex.pm/packages/gleesend)
4[](https://hexdocs.pm/gleesend/)
5
6```sh
7gleam add gleesend@2
8```
9
10```gleam
11import gleesend.{Resend}
12import gleesend/emails.{create_email, to_response, to_request, with_html, BadRequestError}
13import gleam/hackney
14import gleam/result.{try}
15
16pub fn main() {
17 let client = Resend(api_key: "// Replace this with your resend api key")
18
19 let request =
20 create_email(
21 client:,
22 from: "from@example.com",
23 to: ["to@example.com"],
24 subject: ":)",
25 )
26 |> with_html("<p>Successful response</p>")
27 |> to_request()
28
29 use response <- try(
30 request
31 |> hackney.send
32 |> result.replace_error(BadRequestError),
33 )
34
35 // Optional to_response function that parses the response body and status
36 // and returns a result with types for you to handle in your app
37 let response = to_response(response.body, response.status)
38}
39```
40
41Further documentation can be found at <https://hexdocs.pm/gleesend>.
42
43## Development
44
45```sh
46gleam test # Run the tests
47```