Slactionmailer is a mailer for ActionMailer that sends your message to a Slack channel.
Simple include the gem in your gemfile.
gem 'slactionmailer'
Or install from the command line.
gem install slactionmailer
In your environment or .env
file, declare the following variables:
SLACK_WEBHOOK_URL=your incoming webhook url
SLACK_CHANNEL=#your slack channel
SLACK_USERNAME=SlactionMailer (or whaterver you want to call it)
Slactionmailer can be used as the default mailer
#config/environments/development.rb
config.action_mailer.delivery_method => :slack
Or only be used for certain messages
def notification
mail(:from => '[email protected]',
:to => '[email protected]',
:subject => 'Subject',
:delivery_method => :slack)
end
Either way, your mailer messages will appear like this:
If you want to change the default message template, add the following to your config
config.slaction_mailer.template = File.read('my_template.text.erb')
##About
Slactionmailer uses slack-notify
to communicate with Slack and takes inspiration from the letter-opener
gem.
This project rocks and uses MIT-LICENSE.