GithubHelp home page GithubHelp logo

macbury / sidekiq_mailer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from squidpunch/sidekiq_mailer

0.0 3.0 0.0 105 KB

An easy migration from resque to sidekiq for queuing mail deliveries assuming you previously were using resque_mailer

License: MIT License

Ruby 100.00%

sidekiq_mailer's Introduction

SidekiqMailer

A gem plugin which allws messages prepared by ActionMailer to be delivered asynchronously using Sidekiq.

Sidekiq provides an ActionMailer delayed extention which allows you to delay mail in this format

UserMailer.delay.send_welcome_email(new_user)

However if you previously used ResqueMailer you previously have your delayed mails configured like this

UserMailer.send_welcome_email(new_user).deliver

This gem allows a sidekiq queuing system without having to change all mailer calls within your project.

Installation

Install the gem:

gem install sidekiq_mailer

If you're using Bundler to manage your dependencies, you should add it to your Gemfile:

gem 'sidekiq_mailer'

Usage

Include Sidekiq::Mailer in your ActionMailer subclass(es) like this:

class MyMailer < ActionMailer::Base
  include Sidekiq::Mailer
end

Now, when MyMailer.subject_email(params).deliver is called, an entry will be created in the job queue.

Note that you can still have mail delivered synchronously by using the bang method variant:

MyMailer.subject_email(params).deliver!

Testing

You don't want to be sending actual emails in the test environment, so you can configure the environments that should be excluded like so:

# config/initializers/resque_mailer.rb
Sidekiq::Mailer.excluded_environments = [:test, :cucumber]

Note: Define current_env if using Sidekiq::Mailer in a non-Rails project:

Resque::Mailer.current_env = :production

Credits

This is project started with resque_mailer as a base, then migrated to a Sidekiq based system leveraging the built in ActionMailer delay extention

sidekiq_mailer's People

Contributors

macbury avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.