Outbox::Rails
Rails Railtie for sending email, SMS, and push notifications using the Outbox gem. Please view the Outbox documentation to understand the philosophy behind this interface and how to use it.
Installation
Add this line to your application's Gemfile:
gem 'outbox-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install outbox-rails
Usage
Outbox::Notifier uses a very similar interface to ActionMailer.
First, define a notifier in app/notifiers:
class AccountNotifier < Outbox::Notifier
default email: { from: '[email protected]' },
sms: { from: '+15551234567' }
def welcome
# Compose message types using the Outbox::Message interface
email do
subject 'Welcome to our App!'
end
sms do
body 'Welcome to our App!'
end
# Render the body of the message. This is analogous to ActionMailer::Base#mail,
# but unlike in ActionMailer, #render_message is not required.
end
end
Send a message using the deliver method:
# Unlike ActionMailer, deliver takes a single argument that defines the recipients
# for the message types you want to send.
AccountNotifier.welcome.deliver email: '[email protected]', sms: '+15557654321'
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
