gleesend
gleam add gleesend@2
import gleesend.{Resend}
import gleesend/emails.{create_email, to_response, to_request, with_html, BadRequestError}
import gleam/hackney
import gleam/result.{try}
pub fn main() {
let client = Resend(api_key: "// Replace this with your resend api key")
let request =
create_email(
client:,
from: "from@example.com",
to: ["to@example.com"],
subject: ":)",
)
|> with_html("<p>Successful response</p>")
|> to_request()
use response <- try(
request
|> hackney.send
|> result.replace_error(BadRequestError),
)
// Optional to_response function that parses the response body and status
// and returns a result with types for you to handle in your app
let response = to_response(response.body, response.status)
}
Further documentation can be found at https://hexdocs.pm/gleesend.
Development
gleam test # Run the tests