Send emails with Ruby — Resent

Gem version Downloads License Docs

Documentation · Website · RubyGems · GitHub

Resent Ruby SDK

The official Ruby library for Resent transactional email.

Install

gem install resent

Or add to your Gemfile:

gem "resent"
bundle install

Setup

  1. Verify a sending domain in the Resent dashboard
  2. Create an API key under Settings → API keys
  3. Store it as RESENT_API_KEY
require "resent"

resent = Resent.new(ENV.fetch("RESENT_API_KEY"))

Usage

require "resent"

resent = Resent.new(ENV.fetch("RESENT_API_KEY"))

result = resent.emails.send(
  from: "Acme <noreply@yourdomain.com>",
  to: "you@example.com",
  subject: "Hello World",
  html: "<p>Congrats on sending your <strong>first email</strong> with Resent!</p>"
)

puts result["submission_id"]

Send email using HTML

result = resent.emails.send(
  from: "Acme <noreply@yourdomain.com>",
  to: ["you@example.com"],
  subject: "Hello World",
  html: "<strong>It works!</strong>"
)

Send email using text

result = resent.emails.send(
  from: "Acme <noreply@yourdomain.com>",
  to: "you@example.com",
  subject: "Hello World",
  text: "It works!"
)

Docs

License

MIT © Resent