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

1. Setup your environment

Add these lines of code into your environment config file.

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address   => '',
  :port      => 465,
  :user_name => 'resend',
  :password  => ENV['RESEND_API_KEY'],
  :tls => true

2. Send email using Rails Action Mailer

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 SMTP Example

See the full source code.