Skip to content

geetotes/slactionmailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 => '[email protected]',           
       :to => '[email protected]', 
       :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 => '[email protected]',           
       :to => '[email protected]', 
       :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.

About

Send ActionMailer messages to Slack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published