To get the most out of this guide, you’ll need to:

1. Install

Get the Resend Ruby SDK.

2. Send email using Rails Action Mailer

This gem can be used as an Action Mailer delivery method.

First, let’s update or create your mailer initializer file with your Resend API Key.

Resend.api_key = "re_123456789"

Add these lines of code into your environment config file.

config.action_mailer.delivery_method = :resend

Then create a UserMailer class definition.

class UserMailer < ApplicationMailer
  default from: 'Acme <>' # this domain must be verified with Resend
  def welcome_email
    @user = params[:user]
    @url = ''
    mail(to: [""], subject: 'hello world')

And create your ERB email template.

<!doctype html>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <h1>Welcome to, <%= %></h1>
    <p>You have successfully signed up to,</p>
    <p>To login to the site, just follow this link: <%= @url %>.</p>
    <p>Thanks for joining and have a great day!</p>

Initialize your UserMailer class. This should return a UserMailer instance.

u = name: "derich"
mailer = UserMailer.with(user: u).welcome_email

# => #<Mail::Message:153700, Multipart: false, Headers: <From:>, <To:>, <Subject: hello world>, <Mime-Version: 1.0>...

Finally, you can now send emails using the deliver_now! method:


# => {:id=>"a193c81e-9ac5-4708-a569-5caf14220539", :from=>....}

3. Try it yourself

Rails Example

See the full source code.