Gleam SendGrid

Package Version Hex Docs

A client for SendGrid’s API, enabling Gleam programs to send emails.


Add this package to your Gleam project.

gleam add gleam_sendgrid

And then send some emails!

import gleam/sendgrid
import gleam/hackney

pub fn main() {
  let api_key = "your SendGrid API key here"

  // Construct an email
  let email = 
      to: [""],
      sender_email: "",
      sender_name: "Mike",
      subject: "Hello, Joe!",
      content: sendgrid.TextContent("System still working?"),

  // Prepare an API request
  let request = sendgrid.dispatch_request(email, api_key)

  // Send it with a HTTP client of your choice
  assert Ok(response) = hackney.send(request)

  // A status of 202 indicates that the email has been sent
  assert 202 = response.status