Gleam SendGrid
A client for SendGrid’s API, enabling Gleam programs to send emails.
Usage
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 =
sendgrid.Email(
to: ["joe@example.com"],
sender_email: "mike@example.com",
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
let assert Ok(response) = hackney.send(request)
// A status of 202 indicates that the email has been sent
let assert 202 = response.status
}