Skip to content

lpil/sendgriddle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sendgriddle

Package Version Hex Docs

Send emails from Gleam with SendGrid.

Usage

gleam add sendgriddle
import 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)
}

About

A client for the SendGrid transactional email API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages