Send emails from Gleam with SendGrid.
gleam add sendgriddleimport sendgriddle
import gleam/httpc
pub fn main() {
let api_key = "your SendGrid API key here"
// Construct an email
let email =
sendgriddle.Email(
to: ["[email protected]"],
sender_email: "[email protected]",
sender_name: "Mike",
subject: "Hello, Joe!",
content: sendgrid.TextContent("System still working?"),
)
// Prepare an API request
let request = sendgriddle.mail_send_request(email, api_key)
// Send it with a HTTP client of your choice
let assert Ok(response) = httpc.send(request)
// Check the mail send succeeded
assert sendgriddle.mail_send_response(response) == Ok(Nil)
}