Send emails with Sinatra
Prerequisites
Section titled “Prerequisites”Before you start, you'll need:
- A Resend API key
- A verified domain
Install
Get the Resend Ruby SDK.
RubyGems gem install resendGemfile gem 'resend'Send email using HTML
The easiest way to send an email is by using the
htmlparameter.index.rb require "sinatra" require "resend" set :port, 5000 set :bind, "0.0.0.0" Resend.api_key = ENV["RESEND_API_KEY"] get "/" do content_type :json params = { from: 'Acme <onboarding@resend.dev>', to: ['delivered@resend.dev'], subject: 'hello world', html: '<strong>it works!</strong>', } Resend::Emails.send(params).to_hash.to_json end
Examples
Section titled “Examples”Sinatra App
Full Sinatra web application
Basic Send
Basic email sending
Attachments
Send emails with file attachments
Templates
Send emails using Resend hosted templates
Scheduling
Schedule emails for future delivery
Audiences
Manage contacts and audiences
Domains
Create and manage sending domains
Inbound Webhooks
Receive and process inbound emails
Double Opt-in
Double opt-in subscription flow