0.01
No commit activity in last 3 years
No release in over 3 years
Want to send the emails generated by your Ruby on Rails application to a Slack channel? Now you can!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Slactionmailer

Slactionmailer is a mailer for ActionMailer that sends your message to a Slack channel.

Gem Version

Installation

Simple include the gem in your gemfile.

gem 'slactionmailer'

Or install from the command line.

gem install slactionmailer

Setup

In your environment or .env file, declare the name of your mailer variables:

SLACK_WEBHOOK_URL=your incoming webhook url
SLACK_CHANNEL=#your slack channel
SLACK_USERNAME=SlactionMailer (or whaterver you want to call it)

SLACK_CHANNEL and SLACK_WEBHOOK_URL are optional. If you do not set them here, you must pass in a webhook url and channel in your mailer.

Usage

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 => 'from@example.com',           
       :to => 'to@example.com', 
       :subject => 'Subject',
       :delivery_method => :slack)
end

If you want to send messages to multiple channels, simply call the mail method with extra parameters:

def notification
  mail(:from => 'from@example.com',           
       :to => 'to@example.com', 
       :subject => 'Subject',
       :channel => '#yourChanel'
       :webhook => 'https://your-webhook-url'
       :delivery_method => :slack)
end

Your mailer messages will appear like this: image

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.