Skip to content

Vici37/cr-sendgrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crystal Sendgrid

This library provides a client interface to Sendgrid's mailing API.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      sendgrid:
        github: vici37/cr-sendgrid
  2. Run shards install

Usage

require "sendgrid"


client = Sendgrid::Client.new("SENDGRID_API_KEY")

# `message` is a helper method that will handle the construction of the Sendgrid::Message that gets sent through `send`.
# For the full suite of features the Sendgrid Send Mail API provides, you can use all of the constructs defined
# in ./src/sendgrid/sendgrid_structs.cr directly
message = client.message(
  # The `to` param accepts a single email address, a hash (seen below), or a list of email addresses (strings)
  to: {"Fred Flinstone" => "fred@flinstone.com", "Wilma Flinstone" => "wilma@flinstone.com"},
  # Also accepts a single string for the email, or a named tuple for name, email (below)
  from: {name: "Barny Rubble", email: "barny@rubble.com"},
  subject: "Dino got out again",

  content: "Did you know?"
  )

# Send the email
client.send(message)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published