๐ฒResend
This guide outlines how to install and configure the Resend Gem for sending transactional emails in your Lightning Rails project.

Recommended: Use the code generator for a 1-line setup from the terminal and skip all the manual setup ๐
bash generators/setup_resend.sh
Or follow these steps:
Step 1: Create a Resend Account
Go to the Resend website.
Sign up and create an account to access your API key.
Step 2: Add the Resend Gem
Open your
Gemfile.Add the Resend gem in your Gemfile:
Run
bundle installin your terminal to install the gem.
Step 3: Configure Your API Key
Locate your API key from the Resend dashboard.
Add the API key to your
.envfile:
Step 4: Set Up Action Mailer
Development Environment: Open
config/environments/development.rband set the delivery method to:letter_openerfor testing emails locally (The Gem is already installed in the boilerplate):Production Environment delivery method: Open
config/environments/production.rband set the delivery method to:resend:API key in production
Create a new initializer file:
touch app/config/initializers/mailer.rbPaste your API key, and make sure your API key is set in your hosting provider:
(Optional) Welcome Email
Step 5: Create Your First Mailer
Generate a new mailer:
Open the newly created file
app/mailers/user_mailer.rband define a mailer method. For example:
Step 6: Add HTML Content for the Email
Create a corresponding view file for the mailer:
Path:
app/views/user_mailer/welcome_email.html.erbContent example:
Step 7: Initialize and Send the Mailer
Open the Rails console:
Initialize the mailer with a sample user object:
Send the email:
Add an auto-welcome message to welcome your users in
user.rb
Step 8: Verify the Email
Check the recipient's inbox to confirm the email has been sent successfully.
If testing in development, verify the email opens correctly using the
letter_openergem.
That's it! Youโve successfully set up the Resend Gem for sending transactional an marketing emails in your Lightning Rails project, you can enjoy 100 free emails per month.
Last updated
Was this helpful?