The customerio-rails
gem is a drop-in ActionMailer adapter to send emails via Customer.io.
The gem has been created for fast implementation and targets Customer.io’s transactional email capabilities.
You will need a Customer.io account set up to use it.
- Rails 8.0
- Rails 7.0
Generate an App API Key (this is different than the pair Site ID / API Key) from your Workspace Settings > Your Workspace > Manage API Credentials > App API Keys.
Add customerio-rails
to your Gemfile and run bundle install
.
gem 'customerio-rails'
Set Customer.io as your preferred mail delivery method via config/application.rb
:
config.action_mailer.delivery_method = :customerio
config.action_mailer.customerio_settings = { app_api_key: '<Your APP API Key>', region: Customerio::Regions::US }
Use it as you would usually:
class MyMailer < ApplicationMailer
def whatever # whatever.{html,text}.erb will be used as body
mail to: '[email protected]', subject: 'Hello from Rails!'
end
end
Or rely on Customer.io's templated messages with:
class MyMailer < ApplicationMailer
def whatever_with_template
mail to: '[email protected]', subject: 'Hello from Rails!', transactional_message_id: 3, message_data: { myvar: 'a value', another_one: 42x }
end
end
The Customer.io Rails gem is licensed under the MIT license. Refer to the LICENSE file for more information.