Project

mail_queue

0.0
No commit activity in last 3 years
No release in over 3 years
Delivery method for Mail gem. Delivers mail to a beanstalk queue
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0.rc.5
~> 2.4.0

Runtime

~> 2.2.14
>= 0.6.1
 Project Readme

MailQueue

MailQueue is an asynchronous mail delivery method for the Mail gem. It delivers mail to a Beanstalk queue. Worker processes can then pick up the mail from the queue and send it on over SMTP or the like.

Installation

gem install mail_queue

Configuration

  • Mail gem:
Mail.defaults { delivery_method MailQueue::Beanstalk, :tube => 'rculosis' }>
  • Rails:
ActionMailer::Base.delivery_method = MailQueue::Beanstalk

or, if you insist on changing the default options:

ActionMailer::Base.add_delivery_method(:beanstalk, MailQueue::Beanstalk)
ActionMailer::Base.beanstalk_settings = {
  :tube => "email"
}
ActionMailer::Base.delivery_method = :beanstalk

options are:

  • :pri priority, from 0 to 2^32, 0 being the highest, 65536 the default

  • :ttr time to run, default 120 (seconds)

  • :delay how many seconds before the job is put on the ready queue (default 0)

  • :tube tube name used on beanstalk, defaults to 'email.send'

Worker

Have a worker pull the mails off the queue. For example, using Stalker:

smtp = Net::SMTP.new('smtp.example.com', 25)
job 'email.send' do |args|
  smtp.start('example.com', 'me', 'mypassword', 'plain') do |smtp|
    smtp.sendmail(args['message'], args['from'], args['destinations'])
  end
end 

See Stalker documentation for how to run a job.

Meta

Created by Han Kessels

Released under the MIT License: http://www.opensource.org/licenses/mit-license.php

http://github.com/han/mailqueue