Class: MailQueue::Beanstalk
- Inherits:
-
Object
- Object
- MailQueue::Beanstalk
- Defined in:
- lib/mail_queue.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(options = {}) ⇒ Beanstalk
constructor
A new instance of Beanstalk.
Constructor Details
#initialize(options = {}) ⇒ Beanstalk
6 7 8 9 10 11 12 13 |
# File 'lib/mail_queue.rb', line 6 def initialize( = {}) self.settings = { :pri => 65536, :delay => 0, :ttr => 120, :tube => 'email.send' }.merge!() end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
15 16 17 |
# File 'lib/mail_queue.rb', line 15 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mail_queue.rb', line 18 def deliver!(mail) # render mail and push onto queue envelope_from = mail.return_path || mail.sender || mail.from_addrs.first if envelope_from.blank? raise ArgumentError.new('A sender (Return-Path, Sender or From) is required to send a message') end destinations ||= mail.destinations if mail.respond_to?(:destinations) && mail.destinations if destinations.blank? raise ArgumentError.new('At least one recipient (To, Cc or Bcc) is required to send a message') end ||= mail.encoded if mail.respond_to?(:encoded) if .blank? raise ArgumentError.new('Encoded content is required to send a message') end envelope = { :from => envelope_from, :destinations => destinations, :message => } Stalker.enqueue(settings[:tube], envelope, settings) self end |