Resend
This guide outlines how to install and configure the Resend Gem for sending transactional emails in your Lightning Rails project.
Last updated
Was this helpful?
This guide outlines how to install and configure the Resend Gem for sending transactional emails in your Lightning Rails project.
Last updated
Was this helpful?
Go to the Resend website.
Sign up and create an account to access your API key.
Open your Gemfile
.
Add the Resend gem in your Gemfile:
Run bundle install
in your terminal to install the gem.
Locate your API key from the Resend dashboard.
Add the API key to your .env
file:
Development Environment: Open config/environments/development.rb
and set the delivery method to :letter_opener
for testing emails locally (The Gem is already installed in the boilerplate):
Production Environment delivery method: Open config/environments/production.rb
and set the delivery method to :resend
:
API key in production
Create a new initializer file: touch app/config/initializers/mailer.rb
Paste your API key, and make sure your API key is set in your hosting provider:
Generate a new mailer:
Open the newly created file app/mailers/user_mailer.rb
and define a mailer method. For example:
Create a corresponding view file for the mailer:
Path: app/views/user_mailer/welcome_email.html.erb
Content example:
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
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_opener
gem.
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.