The create_send_rails
Gem drops into ActionMailer and sends transactional emails via the Campaign Monitor API, using its Smart Email feature.
It updates ActionMailer so it defaults to JSON mailer views and allows you to define the data required for each of your mailers.
To get started, add the following line to your applications Gemfile
:
gem 'createsend-rails'
Then update your environment files and set delivery_method
to create_send
and include your CampaignMonitor api_key
within the settings block.
config.action_mailer.delivery_method = :create_send
config.action_mailer.create_send_settings = {
api_key: 'INSERT_API_KEY'
}
Now go into your views/*_mailer/
and add a .json
view, which defines the data attributes required by your Smart Email template. Below is an example of a password reset email.
{
"smart_email_id": "SMART_EMAIL_ID",
"language": "<%= @user.language %>",
"name": "<%= @user.name %>",
"reset_url": "<%= @edit_password_reset_url %>"
}
Developed and maintained by Made Tech Ltd. Key contributions:
Copyright © 2016 Made Tech Ltd. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.